Friday, May 15, 2015

Limit for PostreSQL, MySQL and Top for SQL Server

Limit for PostreSQL, MySQL and Top for SQL Server


If you need to select only one record in a query you can use this examples:



  • PostregSQL 


SELECT field FROM table WHERE condition = 'abc' LIMIT 1 --(Retrieve 1 row)


  • SQL Server


SELECT field FROM table WHERE condition = 'abc' LIMIT 1 --(Retrieve 1 row)


  • MySQL


SELECT field FROM table WHERE condition = 'abc' LIMIT 1 --(Retrieve 1 row)

Range
SELECT field FROM table WHERE condition = 'abc' LIMIT 5,10; --(Retrieve 1 rows 6-15)

No comments:

Post a Comment