Any help is appreciated --
1064 - 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 'as receiverimage, re.fName as receiverfName , re.lName as receiverlName , re.add' at line
SELECT co.*,
if(( co.senderid = 1) , ( re.image as receiverimage, re.fName as receiverfName , re.lName as receiverlName , re.address as receiverAddress , re.city as receivercity , re.state as receiverstate, re.country as receivercountry, re.zipCode as receiverzip),(se.address as senderAddress,se.city as sendercity , se.state as senderstate , se.country as sendercountry , se.zipCode as senderzip , se.image as senderimage ,se.fName as senderfName, se.lName as senderlName ))
FROM contacts as co
LEFT JOIN users as se ON( se.id = co.senderid )
LEFT JOIN users as re ON( re.id = co.receiverid )
where (senderid = 1 OR receiverid = 1)
-- is that selecting multiple fields on join table is not valid with or something else ?
I am unable to figure out the exact reason , basic prob. here is to select few fields based on if condition from user table based on join.
Aucun commentaire:
Enregistrer un commentaire