2013-07-06 65 views
8

我有这样的MySQL脚本:SELECT TOP错误

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

生成此错误:

#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 

问题是什么?

+2

有多难它是在手册中查找这个吗? –

回答

18

有mysql中没有TOP

使用极限2

SELECT * FROM produse ORDER BY id_produs DESC LIMIT 2 
5

使用LIMIT代替:

SELECT * 
FROM produse 
ORDER BY id_produs DESC 
LIMIT 2