$query = "SELECT
table1.first_name,
table1.id,
table1.profile_image
FROM table1,table2
WHERE table1.id = (
CASE
WHEN '$id' = table2.id1
THEN
table2.id2
WHEN '$id' = table2.id2
THEN
table2.id1
)
AND table2.case='done'";
This query is failing and I can't figure out why... What I want is to obtain a join on ids between table1 and table2. The thing is table2 has two id fields and I don't know if the Id I want is in field id1 or id2. Then join the other id (NOT $id, but the partner from $id in table2) to the id in table1...