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) Quote Link to comment 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; Quote Link to comment 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. Quote Link to comment 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.