reggie reggie - 1 year ago 136
SQL Question

Difference between Top and Limit Keyword in SQL

A quick Question. Suppose I have the following two queries:

SELECT TOP 2 * FROM Persons;


SELECT * FROM Persons limit 2;

I want to know the difference between the execution of the above 2 queries?
Basically, I want to know when should I use the
keyword and when it is appropriate to use the
Also, How does the database return results based on the above 2 queries.

Answer Source

If you are using SQL Server use TOP if you are using MySQL or Postgres use Limit!

AFAIK there is no product that currently supports both. Here's one list of current implementations and here's another (covers more products but in less detail)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download