vikrant vikrant -4 years ago 95
SQL Question

TOP keyword in sql is not working

I am new in sql i am trying to learn sql.
i want to execute a query for nth highest salary when i write query i throw me a error.

i am writing this subquery

SELECT TOP 3 salary FROM salary ORDER BY SALARY DESC;

now thi is showing me a error

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


my query is correct but i am unable to understood the problem with this.
Limit 3 is working whether top is not working.

Thanks in advance for helping me.

Answer Source

Equivalent query in mysql.Use LIMIT.TOP is used in SQL Server / MS Access.

SELECT salary FROM salary ORDER BY SALARY DESC LIMIT 3;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download