错误在'on clause''
中说'未知列'd.idspesialis'SELECT a.*, b.*, c.*, e.*,d.*, f.*,g.*
FROM ckehamilan a
INNER JOIN pasien b
ON a.noRM=b.noRM
INNER JOIN ( select idPegawai , NamaPegawai as NamaDokter from tpegawai ) d
ON a.idPegawai=d.idPegawai
LEFT JOIN spesialis e
ON e.idspesialis=d.idspesialis
INNER JOIN ( select idPegawai , NamaPegawai as NamaParamedis from tpegawai ) f
ON a.idparamedis=f.idPegawai
LEFT JOIN imunisasi g
ON a.idimunisasi=g.idimunisasi
INNER JOIN ruang c
ON a.idruang=c.idruang
答案 0 :(得分:1)
您的子查询没有列idspesialis
试试这个,
(
SELECT idPegawai, NamaPegawai AS NamaDokter, idspesialis
FROM tpegawai
) d
您的完整查询应如下所示,
SELECT a.*
, b.*
, c.*
, e.*
, d.*
, f.*
, g.*
FROM ckehamilan a
INNER JOIN pasien b
ON a.noRM = b.noRM
INNER JOIN
(
SELECT idPegawai, NamaPegawai AS NamaDokter, idspesialis
FROM tpegawai
) d
ON a.idPegawai = d.idPegawai
LEFT JOIN spesialis e
ON e.idspesialis = d.idspesialis
INNER JOIN
(
SELECT idPegawai , NamaPegawai AS NamaParamedis
FROM tpegawai
) f
ON a.idparamedis = f.idPegawai
LEFT JOIN imunisasi g
ON a.idimunisasi = g.idimunisasi
INNER JOIN ruang c
ON a.idruang = c.idruang
答案 1 :(得分:0)
在包含别名d
的表中,您没有名为d.idspesialis
的列,因此它会抛出错误。
您的d
表格如下 -
( select idPegawai , NamaPegawai as NamaDokter from tpegawai ) d
并且您尝试将e
添加为
e.idspesialis=d.idspesialis
答案 2 :(得分:0)
您必须在内部选择查询中添加该列以在父查询中使用。检查以下查询:
INNER JOIN ( SELECT idPegawai , NamaPegawai AS NamaDokter, idspesialis FROM tpegawai ) d ON a.idPegawai=d.idPegawai
完整查询:
SELECT a.*, b.*, c.*, e.*,d.*, f.*,g.*
FROM ckehamilan a
INNER JOIN pasien b ON a.noRM=b.noRM
INNER JOIN ( SELECT idPegawai , NamaPegawai AS NamaDokter, idspesialis FROM tpegawai ) d ON a.idPegawai=d.idPegawai
LEFT JOIN spesialis e ON e.idspesialis=d.idspesialis
INNER JOIN ( SELECT idPegawai , NamaPegawai AS NamaParamedis FROM tpegawai ) f ON a.idparamedis=f.idPegawai
LEFT JOIN imunisasi g ON a.idimunisasi=g.idimunisasi
INNER JOIN ruang c ON a.idruang=c.idruang
答案 3 :(得分:0)
试试这个::
select a.*, b.*, c.*, e.*,d.idPegawai, d.NamaPegawai as NamaDokter, g.*, f.*
from ckehamilan a
INNER JOIN pasien b ON a.noRM=b.noRM
INNER JOIN tpegawai d ON a.idPegawai=d.idPegawai
LEFT JOIN spesialis e ON e.idspesialis=d.idspesialis
LEFT JOIN imunisasi g ON a.idimunisasi=g.idimunisasi
INNER JOIN tpegawai f ON a.idparamedis = f.idPegawai
INNER JOIN ruang c ON a.idruang=c.idruang