Hello i have two tables:
**prices**
id
id_stock
price
date
**stocks**
id
stock_name
active
now i have to set stocks.active=0
for each stocks that has the MAX(prices.date) > 15 days
(of a date i have to pass)
This is my query, but it's very very slow!!!
update stocks set stocks.active=0 where stocks.id IN (
SELECT prices.id_stock
FROM prices
GROUP BY prices.id_stock
HAVING datediff('2010-08-17', MAX( prices.date )) > 15
)
How to optimize it?
Thank you really much!