我的声明如下:

SELECT * FROM users WHERE division >= '0' AND division <= '10' AND voice = '0' ORDER BY username DESC LIMIT 0, 10

但是,这不会选择除数等于2的用户
SELECT * FROM users WHERE division >= '1' AND division <= '9' AND voice = '0' ORDER BY username DESC LIMIT 0, 10

将选择用户
这是为什么?谢谢你的帮助。

最佳答案

如果除法是一个数,则使用

SELECT * FROM users WHERE division >= 0 AND division <= 10 AND voice = '0' ORDER BY username DESC LIMIT 0, 10

否则,请先使用Cast Functions将除法转换为数字。

关于php - MySQL语句无法正常工作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18522425/

10-10 05:52