I have the following query:
DELETE FROM table1 
WHERE node_id = ".$id." 
AND date < (
            SELECT
                (MAX(date)- INTERVAL 1 MONTH) 
            from table1  
            WHERE node_id = ".$id."
)
However due to mysql strict mode being enabled i get the error:
ERROR 1093 (HY000): You can't specify target table 'table1' for update in FROM clause
After investigation online i attempted to recreate the query as below:
SELECT 
    * 
FROM table1 as tb1 
INNER JOIN table1 as tb2 
    on tb1.id = tb2.id 
HAVING tb1.date < MAX(tb2.date)-INTERVAL 1 MONTH AND tb1.node_id = 1;
However the result set is returning empty.
I have changed max(tb2.date) to a manually entered date which gave me the results I was expecting.
Any ideas what is going on here?
 
     
    