stefanosn
stefanosn

Reputation: 3324

How do I limit the results of an SQL query?

I want to limit the results of a query in MySQL. I want the query to search 5000 rows but return only 5 of the 50 that found. How is it possible to do this?

Any help appreciated.

Upvotes: 0

Views: 103

Answers (2)

Dirk De Winnaar
Dirk De Winnaar

Reputation: 167

SELECT * FROM ANYTABLE LIMIT 50;

Upvotes: 1

Jemaclus
Jemaclus

Reputation: 2376

This is pretty basic SQL stuff. Check out the LIMIT modifier. You want to do something like:

    SELECT id FROM table LIMIT 5

Upvotes: 7

Related Questions