sql >> Base de Datos >  >> RDS >> Mysql

Mi instrucción sql SELECT JOIN en tres tablas

Si entiendo la pregunta, que para ser honesto no entiendo, ¿estás buscando un sindicato?

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

editar incluido e y f

editar2 Deberá agregar la cláusula where antes de cada unión

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