HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

TOP X of SQL Server in MySQL Analog

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
topsqlmysqlserveranalog

Problem

I am looking for SQL Server TOP (X) Analog in MySQL

In SQL Server:

SELECT
  TOP 5
  Z
...
FROM
ORDER BY Z DESC


How can this be done in MySQL?

ADDED:

I have found for other RDBMS: Returning TOP N Records

Solution

SELECT
...
FROM
ORDER BY
LIMIT 5 [OFFSET 10] --Use offset for paging.


Reference: http://dev.mysql.com/doc/refman/5.1/en/select.html

Code Snippets

SELECT
...
FROM
ORDER BY
LIMIT 5 [OFFSET 10] --Use offset for paging.

Context

StackExchange Database Administrators Q#1115, answer score: 5

Revisions (0)

No revisions yet.