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

  • 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.

主站蜘蛛池模板: 盐亭县| 陇南市| 惠水县| 宜兴市| 怀来县| 名山县| 长阳| 抚顺县| 寻甸| 仲巴县| 凤冈县| 德化县| 新郑市| 无锡市| 偏关县| 德昌县| 老河口市| 通河县| 中江县| 章丘市| 年辖:市辖区| 措美县| 屏山县| 化隆| 龙陵县| 揭东县| 平度市| 长葛市| 青岛市| 恩平市| 大余县| 乌审旗| 开远市| 德格县| 奉贤区| 广元市| 丰台区| 辉南县| 江孜县| 岳池县| 洪洞县|