18

私は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少なくとも 1 つの関連付けられたエントリを持つAすべての行を選択したいと思いますstatus True

select distinct B.id, B.param 
from B
join A on A.type_id = B.type_id
where A.status = true

これは良い方法ですか?

4

2 に答える 2