Answer the question
In order to leave comments, you need to log in
How to search two tables?
There are 2 tables: both wp_posts and wp_reviews.
Please tell me how to update the post status in the wp_posts (`post_status`) table to 'draft' for those posts that have no rows in the wp_reviews table. wp_posts `ID` is equal to wp_reviews `company_id`
i.e. if the record with company_id=2001 does not exist in the wp_reviews table, then for the wp_posts table for the row with ID=2001 we update post_status to 'draft'
Answer the question
In order to leave comments, you need to log in
those. if the record with company_id=2001 does not exist in the wp_reviews table, then for the wp_posts table for the row with ID=2001 we update post_status to 'draft'
update wp_posts p
set p.post_status = 'draft'
where not exists (select 1 from wp_reviews r where r.связующий_ключ = p.связующий_ключ)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question