Fenhopi Posted November 3, 2010 Share Posted November 3, 2010 I have one table called statuses(status, dtime, byuser), and one called wallposts(message, byuser, touser, dtime). I want to show statuses and wallposts on my wall, and I want them to sort by date. I need to be able to distinguish between what's a wallpost and what's a status, seeing as wallposts has a byuser. I'd appreciate help on how I'd go about doing this. What I have found so far, is: SELECT * FROM ( SELECT 'Status' AS what, Status AS StatusOrMessage, byuser, 'n/a' AS touser, dtime FROM statuses UNION SELECT 'Message', Message, byuser, touser, dtime FROM Wallposts ORDER BY dtime DESC LIMIT 20 But I'm not quite sure it's right, seeing as I don't quite understand the query. Thank you in advance! Quote Link to comment https://forums.phpfreaks.com/topic/217644-retrieving-data-from-two-tables-to-view-statuses-and-wallposts-as-on-facebook/ Share on other sites More sharing options...
fenway Posted November 7, 2010 Share Posted November 7, 2010 That isn't a valid query -- but the UNION approach should work. Quote Link to comment https://forums.phpfreaks.com/topic/217644-retrieving-data-from-two-tables-to-view-statuses-and-wallposts-as-on-facebook/#findComment-1131380 Share on other sites More sharing options...
Fenhopi Posted November 8, 2010 Author Share Posted November 8, 2010 Why isn't it a valid query? Quote Link to comment https://forums.phpfreaks.com/topic/217644-retrieving-data-from-two-tables-to-view-statuses-and-wallposts-as-on-facebook/#findComment-1131729 Share on other sites More sharing options...
Mchl Posted November 8, 2010 Share Posted November 8, 2010 Because you have one '(' but none ')' Quote Link to comment https://forums.phpfreaks.com/topic/217644-retrieving-data-from-two-tables-to-view-statuses-and-wallposts-as-on-facebook/#findComment-1131731 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.