我希望两个将这两个查询合并为一个查询
SELECT 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'
还有这个
SELECT 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'
谢谢
答案 0 :(得分:0)
您可以在语句中使用派生表。例如
从(选择...)中选择X,Y作为表1联接(选择...)作为表2等。
请参阅参考
答案 1 :(得分:0)
如果两个查询都可以,只需使用join,然后下面的方法就可以使用
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