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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.