Jump to content

showing the biggest number


vikela

Recommended Posts

i have a table that will have an auto increment field,and i would like to retrieve the record with the biggest number and show the record.how can i be able to do the sql statement because i have tried with the limit but no joy.

Link to comment
Share on other sites

AmandaF, it's uncertain which column the user wants the MAX of. It may not be ID, but your solution is a good one if that is the case. :)

 

If vikela doesn't want the ID, then

 

SELECT ID, colum_that_vikela_wants_the_max_of FROM table ORDER BY column_that_vikela_wants_the_max_of LIMIT 1

 

Of course, if the column isn't unique and more than one row has the max value, then only one of those rows will get returned.  In that case, it would be better to use the max() function.

Link to comment
Share on other sites

AmandaF:

1. No need to select ID.

2. You forgot DESC in your ORDER BY clause.

 

Let's just wait for vikela to reply. Let's not guess.

 

1) I thought vikela would need to be able to identify which row the result belonged to.

2) Thanks for catching that for me.

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.