EchoFool Posted January 15, 2008 Share Posted January 15, 2008 Hey, quick question.. Said i have rows with time stamps... now rows can have an ID but many can have the same if they are related to the same thing. So what i want to do is get one of each record ID which is the youngest. How would i go about doing something like that? Example: 1)Record 3 - 12/04/04 2)Record 3 - 12/04/05 3)Record 4 - 12/04/05 So the two that it will return is : Record 3 (The second one in the list) Record 4 as this is different entirely to the record 3's. Quote Link to comment https://forums.phpfreaks.com/topic/86133-question-about-queries/ Share on other sites More sharing options...
beansandsausages Posted January 15, 2008 Share Posted January 15, 2008 so you want it to order by the newest date? Quote Link to comment https://forums.phpfreaks.com/topic/86133-question-about-queries/#findComment-439869 Share on other sites More sharing options...
revraz Posted January 15, 2008 Share Posted January 15, 2008 I would say you need to re-think how you are doing this. Use a Date field that makes sense for one, and the way you have it now, what's the difference from ID 1 and ID 2? Quote Link to comment https://forums.phpfreaks.com/topic/86133-question-about-queries/#findComment-439888 Share on other sites More sharing options...
EchoFool Posted January 15, 2008 Author Share Posted January 15, 2008 RecordID is the ID of the forum thread. The list above would represent the posts in the thread so : RecordID | Text | posted on | PrimaryID | 3 | test | 12/04/04 | 23232 | So its not uncommon that there will be two of the RecordID but the query is needing to find the "youngest" by finding the youngest "posted on" time stamp.. the above is just an example of my idea. Quote Link to comment https://forums.phpfreaks.com/topic/86133-question-about-queries/#findComment-440262 Share on other sites More sharing options...
beansandsausages Posted January 16, 2008 Share Posted January 16, 2008 well just use a : SELECT * FROM `db` where id=`id` ORDER BY posted on DESC Quote Link to comment https://forums.phpfreaks.com/topic/86133-question-about-queries/#findComment-440649 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.