How to limit the results on a SQL query

Skizit picture Skizit · Jun 27, 2010 · Viewed 10.7k times · Source

I'm wondering is it possible to limit the result of a SQL request?

For example, only return up to 50 rows from:

  SELECT * FROM <table>

thanks.

Answer

dzida picture dzida · Jun 27, 2010

Yes, this is possible. This differs between db engines.

Postgres:

SELECT * FROM <table> LIMIT 50

SQL Server:

SELECT TOP 50 * FROM <table> 

...