看板 Database 關於我們 聯絡資訊
這次希望可以做到一個功能是 在群組新增會員名單 可以不出現已經加入群組的會員 目前有一張資料表稱為t1 他儲存著會員資料 而t2分為群組編號 會員編號 加入者編號 現在是下 select * from user as t1 join group_user as t2 where t2.id=t1.id; 但好像不一定能達到我要的效果 請問該怎麼下才對 又或者在資料表上我能重新做什麼樣的安排 先謝謝各位了 -- Sent from my Windows -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.115.113.239 ※ 文章網址: https://www.ptt.cc/bbs/Database/M.1492358553.A.0F7.html
SeanBoog: Not in 04/17 00:09
moyasi: not in not exists都可以吧 04/17 11:15
streetbad: 查詢結果要的是!? 不要出現已有群組的會員!? 04/17 14:23
su9958: 查詢結果要的是可以加入群組的會員列表 去除掉已在此群組 04/18 11:12
su9958: 的會員 用not in一下可以一下又會錯 謝謝 04/18 11:12
streetbad: select t1.* from t1 04/18 11:36
streetbad: left outer join t2 on t2.ano = t1.ano 04/18 11:36
streetbad: where t2.ano is null 04/18 11:36
streetbad: 找出不存在於t2的t1會員編號與其資料 不確定是否 04/18 11:37
streetbad: 符合你的需求 04/18 11:37