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

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.

主站蜘蛛池模板: 精河县| 石棉县| 黔西县| 桃江县| 朔州市| 彭阳县| 大石桥市| 黎平县| 通道| 滁州市| 子洲县| 游戏| 平遥县| 肇东市| 周口市| 永川市| 安顺市| 筠连县| 汉川市| 岱山县| 陈巴尔虎旗| 上饶市| 南平市| 琼结县| 晴隆县| 金溪县| 伽师县| 元谋县| 滨州市| 肇东市| 北海市| 长海县| 夹江县| 化德县| 秦安县| 武夷山市| 海伦市| 富蕴县| 图木舒克市| 年辖:市辖区| 内黄县|