Re: Sorting two result sets by shared column

Posted 28 April 2018 - 02:49 PM

remember the SQL you helped me earlier? Then I will need to do it all again,
Because except for the 2 tables you helped me that we joined?, there are 2 more. And since you saw the other tables, how difficult will that be to "union" them? until today, the most advanced sql I did was SELECT!

Re: Sorting two result sets by shared column

Posted 28 April 2018 - 04:57 PM

Well.. no. Like I mentioned if these are different tables with different columns/data then they shouldn't be sorted together... at best maybe jam it all into an array in the non-db side.. assuming the array column length matches the table with the longest column.. but even then that gets janky results.

You should step back and reevaluate why you need two disparate tables worth of data sorted together.

Re: Sorting two result sets by shared column

Posted 29 April 2018 - 07:03 AM

modi thank you for the help. You're right - I feel like I am making too much issue of something that should be solved more easily, and instead I went on a bad approach.
I will tell you what I want to do: It's like WhatsApp: You have a list of last message from either "Groups" or "Friends". Now I store these messages in 2 separate tables: group_messages and personal_messages.
So I want to get, like in WhatsApp, the last message on any chat the user is participating, and display that last message sorted by date.

Re: Sorting two result sets by shared column

Posted 29 April 2018 - 08:50 AM

Messages are just messages regardless of who they are from; person or group. I would rework the database relationship.

One message table.
One table that indicates a relationship between a message id and a user id.. depending on how you do 'groups' that could be a one to one with a 'groups table id', or you can make it a many to one relationship.. where one, or more, user ids map to one message id.