Is this query well done? I tried it but it failed somehow... The ids are referred as unique so the correlation between the tables should work but it doesn't...
$query = "SELECT table1.id,table1.field1,table1.field2,table1.field3 FROM table1,table2 WHERE table1.id='(CASE WHEN '5' = table2.id1 THEN table2.id2 WHEN '5' = table2.id2 THEN table2.id1)' WHERE table2.field6='done'";
ERROR:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' = relationships.id1 THEN relationships.id2 WHEN '1' = relationships.id2 THEN ' at line 1