2017-02-28 67 views
-1

我想執行的最高薪水的查詢,當我執行我寫的查詢,我得到以下錯誤:TOP關鍵詞是不工作

SELECT TOP 3 salary FROM salary ORDER BY SALARY DESC; 

和錯誤是:

ERROR 1064 (42000): 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 '3 salary FROM salary ORDER BY SALARY DESC' at line 1

我的查詢是正確的,但我無法理解這個問題。

回答

3

等效查詢中mysql。使用LIMITTOP用於SQL Server/MS Access

SELECT salary FROM salary ORDER BY SALARY DESC LIMIT 3; 
+0

好的謝謝。我工作 – vikrant

3

MySQL沒有TOP。使用LIMIT代替:

SELECT salary FROM salary ORDER BY SALARY DESC limit 3;