tissue901 Posted November 2, 2011 Share Posted November 2, 2011 Im having some trouble here with getting my data to be properly gathered. What im doing is making a messaging system. You don't make messages by subject, rather its just by people. So all my messages towards someone shows up under the same thing. I need to get this data from the table and then order it by the time it was posted. The issue is i have to make 2 selects and then i cant get the date to order properly. $userid_1 = sender, $userid_2 is reciever What i have now, issue is it doesnt sort it by the date: SELECT userid_2 FROM messages WHERE userid_1='$dbid' UNION SELECT userid_1 FROM messages WHERE userid_2='$dbid' adding order by date doesnt work because the date column isnt loaded. Problem with this is you cant just do SELECT userid_2 ,date FROM messages WHERE userid_1='$dbid' UNION SELECT userid_1,date FROM messages WHERE userid_2='$dbid' order by date desc because then the select doesnt stay distinct. Another solution could be adding the distinct property, but id only need one column to be distinct and idk if thats possible. so like SELECT (DISTINCT userid_2) date but thats not allowed. Im so confused, and i bet you are too, but basically its taking a bunch of messages, sorting it by the user and then ordering it by the date. Quote Link to comment Share on other sites More sharing options...
fenway Posted November 2, 2011 Share Posted November 2, 2011 You want to order the results by date, regardless of the table of origin? Quote Link to comment Share on other sites More sharing options...
tissue901 Posted November 2, 2011 Author Share Posted November 2, 2011 What do you mean by the table origin? Quote Link to comment Share on other sites More sharing options...
fenway Posted November 3, 2011 Share Posted November 3, 2011 I mean you don't care why it was found? Quote Link to comment Share on other sites More sharing options...
tissue901 Posted November 3, 2011 Author Share Posted November 3, 2011 I'm trying to find everything with certain usernames that meet a certain condition. I can get it to load it all right but i cant get it to order by the date sent, or i can get it to load all the messages that someones sent a message back and order it by the time, but i cant get it if you send the first message and they don't reply back to it. Quote Link to comment Share on other sites More sharing options...
fenway Posted November 6, 2011 Share Posted November 6, 2011 but i cant get it if you send the first message and they don't reply back to it. Sorry, I don't know what that means 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.