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

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

主站蜘蛛池模板: 兴业县| 江孜县| 宜黄县| 汉中市| 阳朔县| 逊克县| 蓬莱市| 赤水市| 南平市| 定边县| 南涧| 唐海县| 乌兰察布市| 漯河市| 金寨县| 得荣县| 鸡西市| 遵义县| 巫溪县| 布拖县| 钦州市| 襄垣县| 宁远县| 南充市| 靖边县| 鹤峰县| 江北区| 西宁市| 台北市| 大田县| 徐闻县| 济南市| 睢宁县| 松溪县| 英超| 阜新市| 齐河县| 林州市| 康乐县| 张家界市| 错那县|