我有2個表,A,B根據來自其他表的條件在表上選擇記錄?
A: id is primary key and indexed
id, type_id, status
------------------
1, 1, True
2, 1, False
3, 2, False
...
B: (Type) type_id is primary key and indexed
type_id, param
----------
1, 23
2, 35
3, 24
我想在B
其中有status True
select distinct B.id, B.param
from B
join A on A.type_id = B.type_id
where A.status = true
在A
至少1相關的條目這是一個很好的方式選擇所有的行?
更好/更快地解釋您的解決方案如何比OP更好/更快 – Nogard