Calin Mihalache
Calin Mihalache

Reputation: 149

SELECT TOP error

I have this mySQL script:

SELECT TOP 2 * FROM produse ORDER BY `id_produs` DESC

Generates this error:

#1064 - 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 '2 * FROM produse ORDER BY `id_produs` DESC LIMIT 0, 30' at line 1

What is the problem?

Upvotes: 9

Views: 7437

Answers (2)

mishik
mishik

Reputation: 10003

Use LIMIT instead:

SELECT * 
FROM   produse
ORDER  BY id_produs DESC
LIMIT  2

Upvotes: 5

echo_Me
echo_Me

Reputation: 37233

there is no TOP in mysql

use LIMIT 2

   SELECT * FROM produse ORDER BY id_produs DESC LIMIT 2

Upvotes: 25

Related Questions