Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Order by issue

Author  Topic 

ccdavies
Starting Member

11 Posts

Posted - 2012-05-24 : 11:29:09
Hi all.

Can anyone see my mistake here:


SELECT data.entry_id AS entry_id_f
FROM exp_channel_data AS data
WHERE field_id_73 = 'yes'
LIMIT 0, 1
ORDER BY 1 DESC


It keeps showing an error of:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 1 DESC' at line 1

and I cant find the issue.

Thank you

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2012-05-24 : 11:39:44
Yes, you are not using SQL Server..

Otherwise, I would guess its your LIMIT syntax.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-24 : 15:07:00
quote:
Originally posted by ccdavies

Hi all.

Can anyone see my mistake here:


SELECT data.entry_id AS entry_id_f
FROM exp_channel_data AS data
WHERE field_id_73 = 'yes'
LIMIT 0, 1
ORDER BY 1 DESC


It keeps showing an error of:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 1 DESC' at line 1

and I cant find the issue.

Thank you


The error message clearly states you're using MySQL. Please post in some MySQL forums like one at www.dbforums.com to get correct syntax specific help. This is MS SQL Server forum and we deal only with T-SQL related issues

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

ccdavies
Starting Member

11 Posts

Posted - 2012-05-24 : 15:40:06
Sorry guys. I am new to this stuff, didnt even realise it was different :P

Thank you for the link!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-24 : 15:43:07
no problem
you're welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-05-30 : 05:07:27
It is other way. LIMIT should follow ORDER BY

SELECT data.entry_id AS entry_id_f
FROM exp_channel_data AS data
WHERE field_id_73 = 'yes'
ORDER BY 1 DESC
LIMIT 0, 1


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -