为什么在使用offset时where子句不起作用?

时间:2019-05-21 16:56:14

标签: mysql

好吧,我正在建立一个包含多个过滤器的网站,并且在以下查询中它们工作得很好

SELECT * from userInventory  limit 30 offset 0

当我在其中添加where子句以使其变为

时,上述查询返回预期的行数
SELECT * from userInventory where item_rarity = 'IMMORTAL' limit 30 offset 0

因此,where子句不起作用,它会返回我使用的简单选择查询结果

SELECT * from userInventory limit 30 offset 0

但是我需要一个查询,其中where和offset都应该正常工作,例如

SELECT * from userInventory where item_name="name" and item_rarity = 'rarity' and usedBy = "usedBy" limit 30 offset 0

注意:在没有偏移量的情况下,查询正常工作,可以返回预期结果,如果增加偏移量,则结果为null

1 个答案:

答案 0 :(得分:0)

尝试使用排序,例如:

SELECT * from userInventory where item_name="name" and item_rarity = 'rarity' and usedBy = "usedBy" ORDER BY SOME_FIELD DESC_OR_ASC limit 30 offset 0;
相关问题