我的情况: 表AAAA:其他表; (包括column1:user1_seq,column2:user2_seq,...) 表BBBB:用户表;
(user1_seq == email_info || user2_seq ==
email_info)
目前我的查询:
SELECT * FROM AAAA
WHERE
user1_seq = (SELECT seq FROM BBBB WHERE user_email = 'test@mail.com')
OR
user2_seq = (SELECT seq FROM BBBB WHERE user_email = 'test@mail.com')`
但选择查询重复!! ..怎么解决呢???
答案 0 :(得分:0)
试试这个(Inner Join
) -
select AAAA.*
from AAAA
inner join BBBB on (AAAA.user1_seq = BBBB.seq OR AAAA.user2_seq = BBBB.seq)
where BBBB.user_email = 'test@mail.com'
以上语法适用于MS SQL SERVER
。
检查您是否需要Inner
或left join
。