0

3つのテーブルで結合を実行しようとしましたが、私は打たれました

ここで、条件は id = 0 および test =0 および data =0 になります

各テーブルの列数は異なります

3つのテーブルすべてでa、b、cを選択したい。

前もって感謝しますここに画像の説明を入力

4

2 に答える 2

0

正直なところ、どちらがわからないとしても、組合を探していますか?

select a,b,c,0 as e,0 as f, test,data from table1
union
select a,b,c,e,f, test,data from table2
union
select a,b,c,0 as e,0 as f, test,data from table3

e と f を含む編集

edit2各ユニオンの前にwhere句を追加する必要があります

select a,b,c,0 as e,0 as f, test,data from table1
  where test= 1 and data =1 and id =0
union
select a,b,c,e,f, test,data from table2
  where test= 1 and data =1 and id =0
union
select a,b,c,0 as e,0 as f, test,data from table3
  where test= 1 and data =1 and id =0
于 2012-05-01T06:40:57.963 に答える
0

テーブルにリレーションが表示されないのですが、どのように結合を使用できますか? すべてのテーブルの a、b、c レコードを表示したいだけなら、UNION を使用できます。

select a,b,c from tbl_name1
UNION
select a,b,c from tbl_name2
UNION
select a,b,c from tbl_name3
于 2012-05-01T06:43:20.677 に答える