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

mysql combine deux requêtes en une seule requête

utilisez simplement join si deux requêtes sont correctes, alors ci-dessous fonctionnera

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