Update rows in table A NOT present in table B
I need to list (and later update) all the items present in the table art who are never referenced in the table orders_items
table art
- artID - artNameTable orders_items
- itemID - parentIDIf i would be looking only by artID=itemID the query is pretty straightforward
select artID, itemID, artName, parentID
FROM art
LEFT JOIN orders_items ON artId=itemID
WHERE stock1=0 and stock3=0 AND itemID is nu开发者_如何转开发ll
GROUP BY artID;
But the problem is that I need to look in itemID AND parentID
Tryed with a subquery but it takes ages and i had to cancel it (art has 30000 records and orders_items near 200000) In my mind I see an IN() and a GROUP_CONCAT() but I can't get this to work...I like to keep this post from Jeff bookmarked. I'm not sure how it will perform, but it seems like you could do itemID=artID OR parentID=artID
精彩评论