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

mysql combina due query in una query

usa semplicemente join se due query vanno bene, di seguito funzionerà

select t1.PT_PEMBERI,t2.PT_PENERIMA from
(SELECT nl.ID, p.NAMA_PT AS PT_PEMBERI
    FROM perusahaan p
    LEFT JOIN penerima_waralaba pw ON pw.ID_PERUSAHAAN = p.ID
    LEFT JOIN outlet o ON o.ID_PENERIMA_WARALABA = pw.ID
    LEFT JOIN nomor_logo nl ON nl.ID = o.NOMOR_LOGO_WARALABA
    WHERE nl.NOMOR_LOGO = 'WI-0010205-610'
    )t1
  inner join
  (
    SELECT nl.ID,pw.NAMA_PT AS PT_PENERIMA
    FROM penerima_waralaba pw
    LEFT JOIN outlet o ON o.ID_PENERIMA_WARALABA = pw.ID
    LEFT JOIN nomor_logo nl ON nl.ID = o.NOMOR_LOGO_WARALABA
    WHERE nl.NOMOR_LOGO = 'WI-0010205-610
    )t2 on t1.ID=t2.ID