我想检索具有相同国家/地区名称的所有用户,但除了用户之外,我正在与其他用户进行比较。此查询给出了一个错误,指出子查询返回多行。在这方面,任何人都可以帮助我。
#if defined(_WIN32) || defined(_WIN64)
# include <gl/glew.h>
# include <GL/gl.h>
# include <GL/glu.h>
#elif __APPLE__
# include "TargetConditionals.h"
# if (TARGET_OS_IPHONE && TARGET_IPHONE_SIMULATOR) || TARGET_OS_IPHONE
# include <OpenGLES/ES2/gl.h>
# include <OpenGLES/ES2/glext.h>
# else
# include <OpenGL/gl.h>
# include <OpenGL/glu.h>
# include <OpenGL/glext.h>
# endif
#elif defined(__ANDROID__) || defined(ANDROID)
# include <GLES2/gl2.h>
# include <GLES2/gl2ext.h>
#elif defined(__linux__) || defined(__unix__) || defined(__posix__)
# include <GL/gl.h>
# include <GL/glu.h>
# include <GL/glext.h>
#else
# error platform not supported.
#endif
答案 0 :(得分:2)
select *
from users u, address a
where a.email=u.email
and a.country = (select country from address where email = 'ta@gmail.com')
and u.email <> 'ta@gmail.com'
OR
select *
from users u, address a,
(select country from address where email = 'ta@gmail.com') c
where a.email=u.email
and a.country = c.country
and u.email <> 'ta@gmail.com'
答案 1 :(得分:0)
我之前没有理解你的问题。试试这个,
SELECT * FROM users s
JOIN address a on a.email = u.email
WHERE a.country in(SELECT country from address where email = 'ta@gmail.com')
AND a.email != 'ta@gmail.com'
答案 2 :(得分:0)
试试这个:
SELECT * FROM users u, address a
WHERE a.email=u.email
AND u.email != 'ta@gmail.com'
AND a.country IN (SELECT country FROM address WHERE email ='ta@gmail.com');