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
– artName
Table orders_items
– itemID
– parentID
If 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 null
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