看板 Database 關於我們 聯絡資訊
※ 引述《JYHuang (夏天到了,冷不起來了說)》之銘言: : 有Table Product,Feature,Product_Feature : Product是放產品資料的資料 : Feature的架構是一個清單式的列表 : id Feature : 1 DVI : 2 HDMI : 3 DisplayPort : 4 ...... : Product_Feature是對照表 (那些Product有那些Feature) : Pid Fid : 1 1 : 1 2 : 2 1 : 3 1 : 我想挑出同時有DVI 跟HDMI的Pid (只有1符合) : 用where Fid In(1,2)的話 1,2,3都會被包含在內 : where (Fid=1 AND Fid=2) 也不被接受 : 請問有什麼方法可以做交集式的篩選呢? 1.把 fid串起來再比對,MySql有group_concat() 2.配合AP串 SQL做起來滿直覺的…… pid in(select pid...where fid=1) and pid in(select pid...where fid=2) and .. 就是感覺會很慢XD -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.229.202.143
bobju:不會慢,我有時查詢需要同時下數十個這類的條件式,還好.XD~ 05/22 09:16
bobju:當然前提是index有先設好.. 05/22 09:26