3raser Posted November 7, 2012 Share Posted November 7, 2012 Each table has the field id. Is there any way to do something below (code provided doesn't work): SELECT threads.id,threads.title,posts.id,posts.thread FROM threads, posts WHERE threads.username = ? AND posts.username = ? ORDER BY `id` DESC Quote Link to comment Share on other sites More sharing options...
Jessica Posted November 7, 2012 Share Posted November 7, 2012 You need to specify which id. If both, which one first? Quote Link to comment Share on other sites More sharing options...
3raser Posted November 7, 2012 Author Share Posted November 7, 2012 It's hard to explain. I want the results combined, then ordered. I don't want a "segregated" list. Quote Link to comment Share on other sites More sharing options...
Jessica Posted November 7, 2012 Share Posted November 7, 2012 Combined how? You're already joining the tables, specify how they're related. Google inner/left join. Quote Link to comment Share on other sites More sharing options...
3raser Posted November 7, 2012 Author Share Posted November 7, 2012 I'm creating a list that shows all of a user's recent posts and threads. I want to have all the threads/posts mixed together in one list, all descending by their dates (decided to go with dates and not IDs). E.g: Newest [THREAD] Oct/11/12 Oct/10/12 Oct/8/12 ..and so on [THREAD] [THREAD] Latest Quote Link to comment Share on other sites More sharing options...
kicken Posted November 7, 2012 Share Posted November 7, 2012 You'll have to use a UNION and two separate select queries, rather than joining things together like you're currently doing. Quote Link to comment Share on other sites More sharing options...
Zane Posted November 7, 2012 Share Posted November 7, 2012 In order to do such a thing with one query you would need an activity table that contained .. The user id, The activity (like post or thread), an id for the post, and id for the thread, and most importantly the datetime of the action. 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.