Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
SELECT * FROM `experience` WHERE `reqexp` <> '4793' ORDER BY 'lvl' DESC LIMIT 1
这就是我想要做的。我正在为客户制作在线游戏,并且需要能够使用具有随机值的 mysql 查询,并找到与该经验量相关的级别。在这种情况下,我需要找到数据库中已经存在的低于 4793 的下一个值,以便确定玩家的适当级别。有任何想法吗?
而不是 order by lvl(它被错误地用'单引号而不是反引号引用,因此被视为字符串文字),您需要 order byreqexp DESC并仅查找 values < 4793。
lvl
'
reqexp DESC
< 4793
SELECT * FROM `experience` WHERE `reqexp` < 4793 ORDER BY `reqexp` DESC LIMIT 1
如果您仍然需要按 排序lvl,则:
ORDER BY `reqexp` DESC, `lvl`