Mysql
 sql >> Database >  >> RDS >> Mysql

La mia istruzione sql SELECT JOIN su tre tabelle

Se ho capito la domanda, che a dire il vero no, stai cercando un sindacato?

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

modifica inclusi e e f

modifica2 Dovrai aggiungere la clausola where prima di ogni unione

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