我在下面的查询中查询以下两个表:
id | gender | interested_men | interested_wmen | name | dob | email | account | photoURL | timestamp
8 | 1 |0 |1 |Jamie |1987-07-04|jampez77@gmail.com| 1 | https://.|2015-11-16 17:47:33
9 | 0 |1 |1 |Jamima|1987-07-04|jampez87@gmail.com| 1 | https://.| 2015-11-17 14:51:38
id | uid | lat | lng | timestamp
8 | 9 | 53.47213437 | -2.06999151 | 2015-11-17 15:05:37
7 | 8 | 53.47213437 | -2.06999151 | 2015-11-16 17:47:33
这是查询,我希望它返回名为Jamima的用户的详细信息,但我没有得到任何结果。我看不出语法有什么问题,所以我不确定。
SELECT DISTINCT
l.uid ,
u.account ,
(
3959 * acos
(
cos(
radians(53.47213437)
) *
cos(
radians( lat)
) *
cos(
radians( lng) - radians(-2.06999151)
) +
sin(
radians(53.47213437)
) *
sin(
radians( lat )
)
)
) distance,
TIMESTAMPDIFF(YEAR, dob, CURDATE()) AS age
FROM locations l
INNER JOIN users u ON l.uid = u.id
WHERE uid != 8
AND gender = 0
AND account = 1
HAVING distance <= 200
AND age >= 23
AND age <= 33
ORDER BY RAND()
我注意到如果我删除了where子句的性别和帐户部分,我会得到正确的结果。即使它们匹配where子句
答案 0 :(得分:0)
$sqlquery="SELECT * FROM Algebra WHERE email='$currentEmail' AND username='$currentUser' AND 0;";
在您的查询中,而表格为两个人设置了值
答案 1 :(得分:0)
这是MySQL中数据类型的问题。出于某种原因,我将性别和帐户设置为ENUM这一事实造成了问题。我只是将其改为INT,一切都很好。