soltek Posted December 31, 2010 Share Posted December 31, 2010 Hello, I'm trying to code a private message system and got stuck (yup, again) on this part: At the page where the messages are read, I'd like to display all the messages where the same sender and the receiver participate, like this: SELECT * FROM messages WHERE sender = 1 AND receiver = 2 OR sender = 2 AND receiver = 1 ORDER BY date LIMIT 0,10; Is there anyway to do something like that? Thank you. (Again, sorry for the weird Subject, I gave my best) Link to comment https://forums.phpfreaks.com/topic/223103-duplicated-and-or-selectors/ Share on other sites More sharing options...
Pikachu2000 Posted December 31, 2010 Share Posted December 31, 2010 This should do it. SELECT * FROM messages WHERE (sender = 1 AND receiver = 2) OR (sender = 2 AND receiver = 1) ORDER BY date LIMIT 0,10; Link to comment https://forums.phpfreaks.com/topic/223103-duplicated-and-or-selectors/#findComment-1153442 Share on other sites More sharing options...
soltek Posted December 31, 2010 Author Share Posted December 31, 2010 This should do it. SELECT * FROM messages WHERE (sender = 1 AND receiver = 2) OR (sender = 2 AND receiver = 1) ORDER BY date LIMIT 0,10; Oh, awesome. Thank you for your help, Pikachu2000. Link to comment https://forums.phpfreaks.com/topic/223103-duplicated-and-or-selectors/#findComment-1153445 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.