Jump to content

[SOLVED] Select the row id of the minimum value of a given column


ninedoors

Recommended Posts

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.