Re: [SQL ] 查詢table1,2某欄位相異的資料

看板Database作者 (Alien)時間14年前 (2011/12/31 00:26), 編輯推噓2(200)
留言2則, 2人參與, 最新討論串3/3 (看更多)
※ 引述《iwhiori (玉米)》之銘言: : select a.id from a where a.id not in (select b.id from b) : From http://stackoverflow.com 還可以試試 select a.id from a minus select b.id from b 或 a left join b,找出 b 是 null 的: select a.id from a left join b on a.id = b.id where b.id is null not in 一般會建議寫 not exists, 大部份情況下速度會較佳 select a.id from a where not exists (select 1 from b where b.id = a.id) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 183.179.61.91 ※ 編輯: adrianshum 來自: 183.179.61.91 (12/31 00:27)

12/31 01:17, , 1F
推 Alien大大果然厲害! ^^ Exists那段很精采
12/31 01:17, 1F

12/31 10:22, , 2F
推!!精彩!
12/31 10:22, 2F
文章代碼(AID): #1E_UOfcw (Database)
文章代碼(AID): #1E_UOfcw (Database)