我有3个查询来查找我的数据。但我无法结合1个查询并获取我的数据。我该怎么处理我的查询?请帮助我,谢谢。
SELECT distinct pk_pgw_master, fk_kelas, rombel, pk_matpel, nama_rombel as wali_kelas, null as row_group
FROM pgw_master
LEFT JOIN akd_program_ajar ON pgw_master.pk_pgw_master = akd_program_ajar.fk_pgw_master
LEFT JOIN akd_matpel ON akd_program_ajar.fk_matpel = akd_matpel.pk_matpel
LEFT JOIN akd_pengajar ON pgw_master.pk_pgw_master = akd_pengajar.fk_pgw_master
LEFT JOIN akd_wali_kelas ON akd_pengajar.pk_pengajar = akd_wali_kelas.fk_pengajar
LEFT JOIN akd_akademisi ON akd_akademisi.kode_rombel = akd_program_ajar.rombel
WHERE pk_pgw_master = 'pgw050'
第二个查询:
SELECT count(pk_kompetensi_dasar) as jml_kd FROM akd_kompetensi_dasar where fk_mapel='MP1610004' and fk_kelas='2'
第三次查询:
SELECT count(pk_akademisi) as jumlah_siswa FROM akd_akademisi where kode_rombel='XI TPTL 1'
this is three result from 3 query
我怎样才能获得1个结果?
答案 0 :(得分:1)
您可以对所有查询进行别名并在选择查询中选择它们。
SELECT x.a, y.b z.c FROM (SELECT * from a) as x, (SELECT * FROM b) as y ,(SELECT * FROM c) as z
Link让sql小提琴来测试你的查询