我的兩個表都像mysql用不等於加入到具有多行
Table 1
uid mail
1136 [email protected]
1231 [email protected]
而且
Table 2
uid rid
1136 3
1136 7
1231 5
1231 2
所以我想加入這兩個表,並希望得到的結果UID其中去掉表2不等於3.
如果您不瞭解我的要求,請讓我知道。
我的兩個表都像mysql用不等於加入到具有多行
Table 1
uid mail
1136 [email protected]
1231 [email protected]
而且
Table 2
uid rid
1136 3
1136 7
1231 5
1231 2
所以我想加入這兩個表,並希望得到的結果UID其中去掉表2不等於3.
如果您不瞭解我的要求,請讓我知道。
select t1.uid, mail, group_concat(rid) as rids
from table1 t1
left join table2 t2
on t1.uid = t2.uid
group by t1.uid
having not find_in_set(3,rids)
;
那麼什麼是你期望的輸出?你有什麼嘗試? – hims056
SELECT mail FROM users LEFT JOIN users_roles ON(users.uid = users_roles.uid AND users_roles.rid <>'3')。但儘管1136已經擺脫了3,但它依然存在。我不想那 – pravat231