|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I've got this statement to select the last two entries in my db:
SELECT top 2 * FROM Content ORDER BY ContentID desc and it works fine because it selects the last two items entered into the db. However, I only want to be able to select item 2 rather than both 1 and 2. How do I do that? Thanks Mat |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Matthew Stuart schrieb:
> I've got this statement to select the last two entries in my db: > > SELECT top 2 * > FROM Content > ORDER BY ContentID desc > > and it works fine because it selects the last two items entered into the db. However, I only want to be able to select item 2 rather than both 1 and 2. How do I do that? Hi Mat, "TOP 2" is not MySQL? However, MySQL knows LIMIT [1] which is more powerful, try: SELECT * FROM Content ORDER BY ContentID DESC LIMIT 1,1 regards -Ralf [1]: http://dev.mysql.com/doc/refman/5.0/en/select.html |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Regards, Jerry Schwartz The Infoshop by Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 www.the-infoshop.com www.giiexpress.com www.etudes-marche.com > -----Original Message----- > From: Matthew Stuart [mailto:mrs@btinternet.com] > Sent: Thursday, October 25, 2007 6:55 AM > To: MySQL email support > Subject: Select question > > I've got this statement to select the last two entries in my db: > > SELECT top 2 * > FROM Content > ORDER BY ContentID desc > > and it works fine because it selects the last two items entered into > the db. However, I only want to be able to select item 2 rather than > both 1 and 2. How do I do that? > > Thanks > > Mat > [JS] What does adding LIMIT 2,1 do? I'm not sure what "SELECT top 2 *" means. Regards, Jerry Schwartz The Infoshop by Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 www.the-infoshop.com www.giiexpress.com www.etudes-marche.com |
|
![]() |
| Outils de la discussion | |
|
|