这是我要执行的查询,但没有任何结果,如果您需要更多有关此方面的信息,请在下面的评论中提问,我将不胜感激。
SELECT DISTINCT * FROM
users
WHERE ( (height
BETWEEN "139" AND "170" AND language
= "english") AND (active
= "1" AND gender
IN (4525,4526) AND DATEDIFF(CURDATE(), birthday
)/365 >= "22" AND DATEDIFF(CURDATE(), birthday
)/365 <= "55" AND country
= "IT") AND id
NOT IN (SELECT block_userid
FROM blocks
WHERE user_id
= 1) AND id
NOT IN (SELECT like_userid
FROM likes
WHERE user_id
= 1) AND id
NOT IN (SELECT user_id
FROM likes
WHERE like_userid
= 1) AND id
<> "1" ) ORDER BY xlikes_created_at
DESC,xvisits_created_at
DESC,xmatches_created_at
DESC,is_pro
DESC LIMIT 12 OFFSET 0;
我尝试了OR运算符,但当然我不是在寻找OR,我希望所有条件都成立,然后再求结果。
users
}
答案 0 :(得分:0)
为什么需要与众不同?通常用户是唯一的
SELECT DISTINCT * FROM `users`
不要将数字值另存为字符串
`height` BETWEEN "139" AND "170"
您的性别状况反复出现:我不想听起来不敏感,但是这些性别很多。
`gender` IN (4525,4526,1275,1277,1278,1279,1280,1281,1282,1283)
您有2个日期差,第二个没有比较器。 Datediff还会返回数字值而不是字符串
DATEDIFF(CURDATE(), `birthday`)/365 >= "24"
DATEDIFF(CURDATE(), `birthday`)/365 "16"
现在,如果DATEDIFF
上缺少的运算符不能解决问题。直接进入数据库,删除所有条件,并开始一个一个地添加这些条件,直到发现哪个原因返回0行。