我收到了这个错误,我不确定如何使用它。很简单的解释将非常感激。错误:
错误号码:1140
Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
SELECT a.nim,b.nama_mahasiswa,c.j_sks,b.jurusan,b.kelas_program,e.status from tbl_dosen_wali a left join tbl_mahasiswa b on a.nim=b.nim left join (select k.nim,k.kd_jadwal,SUM(l.jum_sks) as j_sks from tbl_perwalian_detail k left join (select x.kd_jadwal, y.jum_sks from tbl_jadwal x left join tbl_mk y on x.kd_mk=y.kd_mk) as l on k.kd_jadwal=l.kd_jadwal) c on a.nim=c.nim left join tbl_perwalian_header e on a.nim=e.nim where a.kd_dosen='D001' group by a.nim
Filename: C:\xampp\htdocs\krs\siakad\system\database\DB_driver.php
Line Number: 330
格式化查询:
SELECT a.nim,
b.nama_mahasiswa,
c.j_sks,
b.jurusan,
b.kelas_program,
e.status
FROM tbl_dosen_wali a
LEFT JOIN tbl_mahasiswa b
ON a.nim = b.nim
LEFT JOIN (SELECT k.nim,
k.kd_jadwal,
Sum(l.jum_sks) AS j_sks
FROM tbl_perwalian_detail k
LEFT JOIN (SELECT x.kd_jadwal,
y.jum_sks
FROM tbl_jadwal x
LEFT JOIN tbl_mk y
ON x.kd_mk = y.kd_mk) AS l
ON k.kd_jadwal = l.kd_jadwal) c
ON a.nim = c.nim
LEFT JOIN tbl_perwalian_header e
ON a.nim = e.nim
WHERE a.kd_dosen = 'D001'
GROUP BY a.nim
答案 0 :(得分:0)
因为错误说您需要在子查询中使用GROUP BY。
试试这个
SELECT a.nim,
b.nama_mahasiswa,
c.j_sks,
b.jurusan,
b.kelas_program,
e.status
FROM tbl_dosen_wali a
LEFT JOIN tbl_mahasiswa b
ON a.nim = b.nim
LEFT JOIN (SELECT k.nim,
k.kd_jadwal,
Sum(l.jum_sks) AS j_sks
FROM tbl_perwalian_detail k
LEFT JOIN (SELECT x.kd_jadwal,
y.jum_sks
FROM tbl_jadwal x
LEFT JOIN tbl_mk y
ON x.kd_mk = y.kd_mk) AS l
ON k.kd_jadwal = l.kd_jadwal
GROUP BY k.nim
^^^^^^^^^^^^^^^^
) c
ON a.nim = c.nim
LEFT JOIN tbl_perwalian_header e
ON a.nim = e.nim
WHERE a.kd_dosen = 'D001'
GROUP BY a.nim