I am not expert in sql and I need help with the following query. It is poorly optmized and it takes too long time to execute.
Is it possible to replace IN() with JOIN() to speed up the query?
How to do it?
SELECT *
FROM shop_orders
WHERE id IN (SELECT orders_id
FROM shop_orders_data
WHERE closed = '1' /*AND backorder='0'*/)
AND id IN (SELECT orders_id
FROM shop_orders_products
WHERE products_id IN (SELECT id
FROM shop_products
WHERE artno = '120000'
OR name LIKE '%120000%'))
ORDER BY created DESC
1 Answer