MySQL - join 2 or more tables with null fields

0

Good morning, I currently have an online questionnaire which to qualify you I must make a union of 2 tables, however, since no person has selected a particular option there is no value to associate and this does not allow me to do the union of both.

the first query is this:

select * from 


        (select  'empresa', 'cargo',  'nombre','cedula','Correo','telefono', left('fecha_registro',10) as fecha,

            CASE WHEN subtipo = 'Autoritario'
                then CASE 
      WHEN count(fecha_registro)*9 <= 9 then 1
      WHEN count(fecha_registro)*9 <= 18 then 2
                WHEN count(fecha_registro)*9 <= 27 then 3
                WHEN count(fecha_registro)*9 <= 36 then 4
                ELSE 5 END end as Autoritario

            from resultados  left join inicial on inicial.base = resultados.respuesta 
            where  subtipo = 'Autoritario'

            group by 'empresa', 'cargo', 'nombre','cedula','Correo','telefono','fecha'

            order by 'fecha' desc) as Autoritario

this gives me the following result:

However, when I add a second query with a join, it does not throw anything at me (I clarify that the second does not contain any value (yet) but soon I would have it

select * from 


        (select  'empresa', 'cargo',  'nombre','cedula','Correo','telefono', left('fecha_registro',10) as fecha,

            CASE WHEN subtipo = 'Autoritario'
                then CASE 
      WHEN count(fecha_registro)*9 <= 9 then 1
      WHEN count(fecha_registro)*9 <= 18 then 2
                WHEN count(fecha_registro)*9 <= 27 then 3
                WHEN count(fecha_registro)*9 <= 36 then 4
                ELSE 5 END end as Autoritario

            from resultados  left join inicial on inicial.base = resultados.respuesta 
            where  subtipo = 'Autoritario'

            group by 'empresa', 'cargo', 'nombre','cedula','Correo','telefono','fecha'

            order by 'fecha' desc) as Autoritario

    join


        (select  'empresa', 'cargo',  'nombre','cedula','Correo','telefono', left('fecha_registro',10) as fecha,

            CASE WHEN subtipo = 'Cambio'
                then CASE 
      WHEN count(fecha_registro)*9 <= 9 then 1
      WHEN count(fecha_registro)*9 <= 18 then 2
                WHEN count(fecha_registro)*9 <= 27 then 3
                WHEN count(fecha_registro)*9 <= 36 then 4
                ELSE 5 END end as Cambio

            from resultados  left join inicial on inicial.base = resultados.respuesta 
            where  subtipo = 'Cambio'

            group by 'empresa', 'cargo', 'nombre','cedula','Correo','telefono','fecha'

            order by 'fecha' desc) as Cambio

and the result is this:

    
asked by Carlos Pulgarin 26.11.2018 в 04:17
source

0 answers