官术网_书友最值得收藏!

  • MySQL 8 for Big Data
  • Shabbir Challawala Jaydip Lakhatariya Chintan Mehta Kandarp Patel
  • 234字
  • 2021-08-20 10:06:13

LIMIT clause

Using LIMIT clause we can retrieve only some amount of rows from the large data chunks. It helps to limit the number of rows returned as a result set. Suppose there are thousands of rows exists in a table but we require only 10 records then this clause helps to fetch only 10 records instead of fetching thousands of records. This really helps to tune the performance while searching on large datasets.

We can pass either one or two arguments with the LIMIT clause. In case of two arguments, one will be an offset which specifies the offset of the first row to return. While the second argument will be count which specifies the maximum number of rows to be returned. This both argument should be zero or in a positive manner. Check the below query where we have fetched rows from the user table starting from the 5th row up to the 10 records.

SELECT * FROM users limit 5 , 10;

If we specify only one argument with the LIMIT clause then the argument will be considered as the number of rows. For example, the following query is used to retrieve 10 rows from the users table:

SELECT * FROM users limit 10;

As of now, we have seen retrieving data from a single table; if we want to retrieve data from multiple tables, JOIN and UNION keywords are used.

主站蜘蛛池模板: 卫辉市| 呈贡县| 莱西市| 衡东县| 克东县| 伊吾县| 峨眉山市| 石狮市| 宁明县| 通州市| 庆元县| 红原县| 松桃| 醴陵市| 天祝| 商河县| 黑水县| 丰原市| 崇义县| 镇康县| 文安县| 中牟县| 贵定县| 玉溪市| 汉阴县| 新野县| 英山县| 天等县| 海口市| 都江堰市| 台东市| 延庆县| 左云县| 文成县| 绥滨县| 元江| 若羌县| 武隆县| 老河口市| 宝山区| 常山县|