我试图做一个看起来像这样的查询:
SELECT `online`.user_id, users.profile_image_url, profile_info.profile_text, users.kind_of_relationship, users.gender_search, users.country
FROM `online`, users, profile_info
WHERE (`online`.user_id = users.id)
AND (`online`.user_id = profile_info.profile_user_id)
AND (users.user_age >= '25' AND users.user_age <= '38')
AND (users.kind_of_relationship = 'Friendship')
AND (users.gender = 'female')
AND users.country IN (SELECT searching_countries.country FROM searching_countries, `online` WHERE `online`.user_id = searching_countries.user_id);
它失败了。
但是,如果我像这样运行此查询
SELECT `online`.user_id, users.profile_image_url, profile_info.profile_text, users.kind_of_relationship, users.gender_search, users.country
FROM `online`, users, profile_info
WHERE (`online`.user_id = users.id)
AND (`online`.user_id = profile_info.profile_user_id)
AND (users.user_age >= '25' AND users.user_age <= '38')
AND (users.kind_of_relationship = 'Friendship')
AND (users.gender = 'female')
AND users.country IN ('Sweden', 'Austria');
然后查询工作正常。
另外,如果我只运行查询:
SELECT searching_countries.country FROM searching_countries, `online` WHERE `online`.user_id = searching_countries.user_id
我得到结果瑞典,奥地利..
任何想法为什么这个IN(SELECT search_countries.country FROM search_countries, online
WHERE online
.user_id = search_countries.user_id) 不想工作?
先感谢您!