在下面的代码中,第4行正在创建错误" AND' user' IN(SELECT' user_s' FROM' sex' WHERE sex =' $ iaminterestedin')"。基本上我试图只包括性别表的user_s列中的用户为sex column = $ iaminterestedin。然而,这产生了一个错误。 WHERE ... NOT IN查询工作正常但是有什么东西如WHERE ... IN查询?
$result = queryMysql("SELECT `user` FROM `members`
WHERE `user` NOT IN(SELECT `ilike` FROM `likeprofile` WHERE user_l='$user')
AND `user` NOT IN(SELECT `dislike` FROM `dislikeprofile` WHERE user_d='$user')
AND 'user' IN(SELECT 'user_s' FROM 'gender' WHERE sex='$iaminterestedin')
AND `user` <> '$user'");
答案 0 :(得分:0)
表名应该用反引号括起来而不是引号
AND `user` IN(SELECT `user_s`
^----^ ^------^ use backticks ` instead of quotes '
答案 1 :(得分:0)
试试这个:
$result = queryMysql("SELECT `user` FROM `members`
WHERE `user` NOT IN(SELECT `ilike` FROM `likeprofile` WHERE user_l='" . $user . "')
AND `user` NOT IN(SELECT `dislike` FROM `dislikeprofile` WHERE user_d='" . $user . "')
AND `user` IN(SELECT `user_s` FROM `gender` WHERE sex='" . $iaminterestedin . "')
AND `user` <> '" . $user . "'");
你应该使用反引号,而不是qoutes。您还需要结束字符串以输入变量。
答案 2 :(得分:0)
AND 'user' IN(SELECT 'user_s' FROM 'gender' WHERE sex='$iaminterestedin')
^----^--- wrong quotes. Use ` instead