ninedoors Posted August 11, 2008 Share Posted August 11, 2008 I would like to be able to select the row id of a given column that has the minimum value in that column. So if I had a column named darts with values (0, 4, 6, 2, 0, 5, 7) in it. How do I select the row id (row_id)for one of the columns with 0 in it. Right now I am trying this but it isn't working: $query = "SELECT row_id, MIN(darts) FROM schedule_temp GROUP BY row_id"; I understand why it isn't working but is there a mysql function that does this or do I have to pull out all the values and compare them in the script? Link to comment https://forums.phpfreaks.com/topic/119186-solved-select-the-row-id-of-the-minimum-value-of-a-given-column/ Share on other sites More sharing options...
ninedoors Posted August 11, 2008 Author Share Posted August 11, 2008 Wow, I'm dumb. I guess I could jsut use ORDER BY and use the first record returned. Link to comment https://forums.phpfreaks.com/topic/119186-solved-select-the-row-id-of-the-minimum-value-of-a-given-column/#findComment-613815 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.