hassank1 Posted May 9, 2009 Share Posted May 9, 2009 I need the best query that will get me all the TopicIDs written by a specific user (UserID) [i know it would be a better idea to save the creatorID with the 1st table,however I didn't think of that back then]. here are the 2 tables : 1- table name : boardtopics fields : TopicID - title 2-table name : boardposts fields : BoardPostID - TopicID - UserID - post - PostDate note: of course the 2nd table may have many posts belonging to the same TopicID but the 1st poster is the one who has the lower PostDate (he posted 1st) thx Quote Link to comment https://forums.phpfreaks.com/topic/157503-get-topics-written-by-a-user/ Share on other sites More sharing options...
Maq Posted May 9, 2009 Share Posted May 9, 2009 Have you even made an attempt to do this? You need a JOIN. Quote Link to comment https://forums.phpfreaks.com/topic/157503-get-topics-written-by-a-user/#findComment-830409 Share on other sites More sharing options...
hassank1 Posted May 9, 2009 Author Share Posted May 9, 2009 I am trying .. but I don't know how to get only the oldest PostID for a specific topic ... :S Quote Link to comment https://forums.phpfreaks.com/topic/157503-get-topics-written-by-a-user/#findComment-830410 Share on other sites More sharing options...
fenway Posted May 9, 2009 Share Posted May 9, 2009 I am trying .. but I don't know how to get only the oldest PostID for a specific topic ... :S You need to find the oldest one FIRST, and join back to your table SECOND. Quote Link to comment https://forums.phpfreaks.com/topic/157503-get-topics-written-by-a-user/#findComment-830414 Share on other sites More sharing options...
hassank1 Posted May 9, 2009 Author Share Posted May 9, 2009 I am thinking to add a field 'CreatorID' to the 1st table.. this would be a better idea in the long term isn't ? Quote Link to comment https://forums.phpfreaks.com/topic/157503-get-topics-written-by-a-user/#findComment-830423 Share on other sites More sharing options...
fenway Posted May 11, 2009 Share Posted May 11, 2009 I am thinking to add a field 'CreatorID' to the 1st table.. this would be a better idea in the long term isn't ? If you're talking about duplicating a field, then "no". Quote Link to comment https://forums.phpfreaks.com/topic/157503-get-topics-written-by-a-user/#findComment-831549 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.