SQL语法,我做错了什么?

时间:2022-09-06 22:38:44

I have the following syntax, and all runs fine except for "LIMIT". All the results of the database display when only 9 results should. I have the "0, 9" coming from variables so they will change on each paginated link (ex. 0, 9; 10, 18; 19, 27; etc.). I checked and rechecked my syntax and I don't understand why all the results would show. Below is the exact query I'm testing.

我有以下语法,除“LIMIT”外,所有运行正常。只有9个结果应该显示数据库的所有结果。我有来自变量的“0,9”,因此它们将在每个分页链接上更改(例如0,9; 10,18; 19,27;等等)。我检查并重新检查了我的语法,我不明白为什么所有的结果都会显示出来。以下是我正在测试的确切查询。

Also to note, I'm using XAMPP

还要注意,我正在使用XAMPP

FROM acb_accfitems WHERE itemtype = 'furniture' ORDER BY price DESC LIMIT 0, 9

2 个解决方案

#1


2  

This way you can do pagination:

这样你就可以做分页:

ORDER BY price LIMIT 10       /* first 10 */
ORDER BY price LIMIT 11, 10   /* second 10 */
ORDER BY price LIMIT 21, 10   /* third 10 */

etc.

#2


0  

ORDER BY price DESC LIMIT 9

按订单价格DESC LIMIT 9

Is what you need.

是你需要的。

#1


2  

This way you can do pagination:

这样你就可以做分页:

ORDER BY price LIMIT 10       /* first 10 */
ORDER BY price LIMIT 11, 10   /* second 10 */
ORDER BY price LIMIT 21, 10   /* third 10 */

etc.

#2


0  

ORDER BY price DESC LIMIT 9

按订单价格DESC LIMIT 9

Is what you need.

是你需要的。