Mysql
 sql >> Base de données >  >> RDS >> Mysql

Mon instruction sql SELECT JOIN sur trois tables

Si j'ai bien compris la question, ce que je ne comprends pas franchement, cherchez-vous un syndicat ?

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

modifier inclus e et f

modifier2 Vous devrez ajouter la clause where avant chaque union

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