简体   繁体   English

如何限制SQL查询的结果?

[英]How do I limit the results of an SQL query?

I want to limit the results of a query in MySQL. 我想限制MySQL查询的结果。 I want the query to search 5000 rows but return only 5 of the 50 that found. 我希望查询搜索5000行,但仅返回找到的50行中的5行。 How is it possible to do this? 这怎么可能呢?

Any help appreciated. 任何帮助表示赞赏。

This is pretty basic SQL stuff. 这是相当基本的SQL东西。 Check out the LIMIT modifier. 检出LIMIT修饰符。 You want to do something like: 您想要执行以下操作:

    SELECT id FROM table LIMIT 5
SELECT * FROM ANYTABLE LIMIT 50;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM