SirChick Posted December 23, 2007 Share Posted December 23, 2007 I have a query which is loading up all users that a particular ID has messaged or been messaged from.....but its checking this over 3 tables.. i gave it a go but i got an error.. was hoping you'd be able to help me: My 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 'IF(Sender='78', Receiver, Sender) as otherPartyID FROM messages UNION SELECT' at line 1 Code: <?php $GetConversation = mysql_query("SELECT * IF(Sender='$ID', Receiver, Sender) as otherPartyID FROM messages UNION SELECT * IF(Sender='$ID', Receiver, Sender) as otherPartyID FROM textmessages UNION SELECT * IF(Sender='$ID', Receiver, Sender) as otherPartyID FROM phonecalls WHERE Sender='$ReportedPlayer' OR Receiver='$ReportedPlayer' GROUP BY otherPartyID ") or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/82977-solved-help-with-query/ Share on other sites More sharing options...
btherl Posted December 24, 2007 Share Posted December 24, 2007 You need to seperate * and the rest of the select list with a comma, like this: SELECT *, IF(Sender='$ID', Receiver, Sender) as otherPartyID Quote Link to comment https://forums.phpfreaks.com/topic/82977-solved-help-with-query/#findComment-422044 Share on other sites More sharing options...
SirChick Posted December 24, 2007 Author Share Posted December 24, 2007 Thank you my friend! Quote Link to comment https://forums.phpfreaks.com/topic/82977-solved-help-with-query/#findComment-422046 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.