- 質問の編集 *
私はテーブルのセットを持っています。2 番目のテーブル t2 をフィルター処理するとき、t1 のすべての行を取得したいと考えています。
SQLスクリプトは以下です。いじりながら近づいている気がするのですが、なかなか実現できません。
つまり、該当する場合は t2 の行が必要ですが、t1 の行はすべて、他の列に null があります。
ありがとう。
テーブル t1 を作成します (id int identity(1,1), parentName varchar(20) null ) テーブル t2 を作成します (id int identity(1,1), t1id int not null, childName varchar(20) null ) テーブル t3 を作成します ( id int identity(1,1), t2id int not null, gChildName varchar(20) null ) t1 (parentName) 値 ('bob') に挿入 t1 (parentName) 値 ('john') に挿入します。 t2 ( childName, t1id ) 値 ( 'irving', 1 ) に挿入 t2 ( childName, t1id ) 値 ( 'parna', 1 ) に挿入 t2 ( childName, t1id ) 値 ( 'mike', 1 ) に挿入 選択する t1.id、 t1.parentName、 t2.id、 t2.childName t1 左外部結合 t2 から t2.t1id = t1.id で どこで t2.childName = 'マイク' -- 私が望むのは: -- 1、ボブ、3、マイク -- 2、ジョン、ヌル、ヌル ドロップテーブル t3 ドロップテーブル t2 ドロップテーブル t1