Hello eveyone! Banging my head against the wall trying to convert this into 4.0.27 - compatible format (no NOT EXISTS, no nestled SELECTs can be used) for a particular server I cannot upgrade. SELECT id AS del_id, parent AS del_parent, isanswer FROM `table1` WHERE isanswer = 1 AND NOT EXISTS ( SELECT id FROM `table1` WHERE id = del_parent) Code (markup): It looks like LEFT JOIN would only help if I'm comparing two tables but I need to do this on a single table. Basically I can only think of a workaround that invloves a SELECT subquery which is not going to fly on pre-4.1 version 'cause you can only have INSERT ... SELECT and REPLACE ... SELECT subqueries. Please help! Cheers, D.
SELECT a.id AS del_id, a.parent AS del_parent, a.isanswer FROM table1 a LEFT JOIN table1 b ON a.parent = b.id WHERE a.isanswer = 1 AND b.id IS NULL Code (markup):
SoKickIt, Sorry for the long delayed thank you I have not checked here for a while and in the meantime actually found the way to upgrade the mySQL instead. I am still doing some performance testing, so I'll use your query design to see if it performs better than the orignial one. Thanks again, D~