Hilly_2004 Posted February 28, 2010 Share Posted February 28, 2010 Is it possible to display data from 2 separate tables and order the way it's displayed based on 2 columns from the separate tables. e.g. forum_members MEMBER_ID | M_FIRSTNAME | M_SURNAME | M_PROFILEUPDATE submissions MEMBER_ID | TITLE | SUMMARY | TIMESTAMP M_PROFILEUPDATE and TIMESTAMP are obviously timestamp records, so hopefully the end goal would be to order the 2 tables based on this columns (the latest being displayed first). Thanks in advance for any help! Quote Link to comment Share on other sites More sharing options...
Mchl Posted February 28, 2010 Share Posted February 28, 2010 The answer is: probably. You have to explain what data you want to display (show an example perhaps). A list of submissions sorted by submission date and then by members' profile update time? Quote Link to comment Share on other sites More sharing options...
Hilly_2004 Posted February 28, 2010 Author Share Posted February 28, 2010 Think of it like a "Recent Activity" widget... e.g. Stephen Hill has updated their profile... (2 hours ago...) Charlotte Morley has posted a submission... (3 hours ago...) The amount of information displayed above can obviously change depending on how in depth I want it to be, but the above is a good start. Quote Link to comment Share on other sites More sharing options...
Mchl Posted March 1, 2010 Share Posted March 1, 2010 So something like this I guess (SELECT 'profileUpdate' AS action, CONCAT(M_FIRSTNAME,' ',M_SURNAME) AS userName, M_PROFILEUPDATE AS ts FROM forum_members LIMIT 10) UNION (SELECT 'submission' AS action, CONCAT(m.M_FIRSTNAME,' ',m.M_SURNAME) AS userName, s.`TIMESTAMP` AS ts FROM forum_members AS m CROSS JOIN submissions AS s USING (MEMBER_ID) LIMIT 10) ORDER BY ts DESC LIMIT 10 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.