MySQL Forums
Forum List  »  InnoDB

Re: LIMIT 1
Posted by: Brent Morgan
Date: May 22, 2007 03:03PM

'limit 1' means that it will only return one value. If that's not what you want, then eliminate it-- it's not required. If you want it to return 5 values, then type 'limit 5'

If that IS what you want, however, I'd recommend adding an 'order by' so that you can make sure you're getting the result you want!

e.g.

SELECT *
FROM table
WHERE id = x
ORDER BY tstamp DESC
LIMIT 1;

this will return the most recent result for a row where id = x (where 'tstamp' is a timestamp)

Options: ReplyQuote


Subject
Views
Written By
Posted
74068
May 21, 2007 08:52AM
Re: LIMIT 1
17048
May 22, 2007 03:03PM
10475
June 04, 2007 08:37AM
7831
April 10, 2008 07:21PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.