Last active
October 13, 2015 01:28
-
-
Save czterystaczwarty/4117714 to your computer and use it in GitHub Desktop.
Update with subselect on the same table.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE | |
product | |
SET | |
product_active = 0, product_date_deleted = NOW() | |
WHERE product_id IN (SELECT product_id | |
FROM (SELECT | |
product.product_id | |
FROM | |
product | |
LEFT JOIN | |
product_image ON (product.product_id = product_image.product_id AND product.product_date_deleted IS NULL) | |
GROUP BY | |
product.product_id | |
HAVING | |
COUNT(product_image.image_id) = 0) product_copy ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment