473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Using TOP in mySQL v4.1

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.

Jan 27 '06 #1
2 10991
"Andrew Chalk" <ac****@magnacartasoftware.com> wrote in message
news:qs*******************@newssvr11.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.
Jan 27 '06 #2
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" <bi**@karwin.com> wrote in message
news:dr*********@enews4.newsguy.com...
"Andrew Chalk" <ac****@magnacartasoftware.com> wrote in message
news:qs*******************@newssvr11.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.

Jan 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Phil Powell | last post by:
I've read some online resources that utilize various MySQL command-line actions to migrate data from Access to MySQL. The situation is this: a group of co-workers of mine will be using an Access...
6
by: das dsf | last post by:
Hi there! I have both PHP 4.0( RPM) installed and MySQL 4.0.20 installed with the mysqld daemon up and running. But when I look at the output of phpinfo() , I do not see it there, which is...
2
by: cocoalearner | last post by:
I am serving a website using apache. All the php and mysql code I have written works, except for one thing. When I try to create a database named M#2 using the following call, no database is...
0
by: Tawfik Rady | last post by:
Hi Everybody, 1- I am trying to upsize an access database to my MySQL server on my website. I tried to get connected within access and failed. Please advise. I am using Win XP as the operating...
0
by: Mark | last post by:
Using a Java program, I can connect to the test database in MySQL. The test database is installed using a MySQL utility, and it can be accessed by any user without supplying a password. The...
1
by: Ted | last post by:
I managed to get it installed OK, along side MS Visual Studio 2005 (with which I received it). During the install, I made sure I installed everything. I have developed a number of applications...
4
by: yogesh | last post by:
mysql in c++ initialize error occurs a simple program is executed in redhat9.0 , using gcc 3.2.2 compiler version ... #include <stdio.h> #include <mysql.h> #include <string.h> int main() {
12
by: MJK | last post by:
Hello everybody, I am almost a new C programmer and now I need to use SQL within my C codes. Does anybody have any idea about good examples on SQL using C? I have not any experience using SQL...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
8
by: NMarks | last post by:
Hello all, I have created a database for my work that stores information for keys/locks, doors and employees. Specifically the database contains all the information of our lock system, which...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.