看板 Database 關於我們 聯絡資訊
table ID element 1 Bi 1 Na 2 Bi 2 Na 2 O 3 Bi 3 C 因為mysql沒有Intersection查詢的功能可用 因此我的問題 1. 我想查出至少包含Bi與Na的ID 也就是查詢結果為 1,2 我原本用select * from table where element='Bi' and element='Na'結果會查出空集合 select * from table where element='Bi' or element='Na' 則會查出 1,2,3 2. 我想查出只有包含Bi與Na兩種元素的ID 也就是查詢結果為 1 請前輩們賜教 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 103.6.151.80
king08:我總覺得這個設計怪怪的,若依需求需要寫程式去查出資料 01/20 22:49
TeemingVoid:改用 inner join 即可,請參照回文的內容。 01/21 00:53