dbTalk Databases Forums  

Using TOP in mySQL v4.1

mailing.database.mysql-win32 mailing.database.mysql-win32


Discuss Using TOP in mySQL v4.1 in the mailing.database.mysql-win32 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Andrew Chalk
 
Posts: n/a

Default Using TOP in mySQL v4.1 - 01-26-2006 , 07:12 PM






Can someone tell me where my syntax is wrong in the following SQL statement.
It's something to do with the use of the TOP keyword:

SELECT distinct top 1 * from calldetails order by calldate desc

I am trying to order the table by calldate and them select the most recent
record.

Many thanks.




Reply With Quote
  #2  
Old   
Bill Karwin
 
Posts: n/a

Default Re: Using TOP in mySQL v4.1 - 01-26-2006 , 08:35 PM






"Andrew Chalk" <achalk (AT) magnacartasoftware (DOT) com> wrote

Quote:
Can someone tell me where my syntax is wrong in the following SQL
statement.
It's something to do with the use of the TOP keyword:
Right -- TOP is not a keyword in MySQL or in standard SQL.

This is a proprietary extension to the SQL language, implemented in
Microsoft SQL Server 7 and later.

Quote:
SELECT distinct top 1 * from calldetails order by calldate desc

I am trying to order the table by calldate and them select the most recent
record.
You can do this in MySQL as follows:

SELECT DISTINCT * FROM calldetails ORDER BY calldate DESC LIMIT 10

See http://dev.mysql.com/doc/refman/5.0/en/select.html

Regards,
Bill K.




Reply With Quote
  #3  
Old   
Andrew Chalk
 
Posts: n/a

Default Re: Using TOP in mySQL v4.1 - 01-27-2006 , 01:26 AM



Thanks, Bill.

That's a very complete answer. I had assumed TOP was standard SQL. That's
what you get for not reading standards.

Regards,

Andrew
"Bill Karwin" <bill (AT) karwin (DOT) com> wrote

Quote:
"Andrew Chalk" <achalk (AT) magnacartasoftware (DOT) com> wrote in message
news:qseCf.28240$PL5.22263 (AT) newssvr11 (DOT) news.prodigy.com...
Can someone tell me where my syntax is wrong in the following SQL
statement.
It's something to do with the use of the TOP keyword:

Right -- TOP is not a keyword in MySQL or in standard SQL.

This is a proprietary extension to the SQL language, implemented in
Microsoft SQL Server 7 and later.

SELECT distinct top 1 * from calldetails order by calldate desc

I am trying to order the table by calldate and them select the most
recent
record.

You can do this in MySQL as follows:

SELECT DISTINCT * FROM calldetails ORDER BY calldate DESC LIMIT 10

See http://dev.mysql.com/doc/refman/5.0/en/select.html

Regards,
Bill K.




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.