0

你们能帮我解决这个问题吗?

错误说''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 
4

4 回答 4

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
于 2012-12-07T07:01:35.453 回答
0

在您的带有 alias 的表中d,您没有名为的列d.idspesialis,因此它会引发错误。

您的d表格如下 -

( select idPegawai , NamaPegawai as NamaDokter from tpegawai )  d 

并且您正在尝试添加加入eas

e.idspesialis=d.idspesialis 
于 2012-12-07T07:02:15.793 回答
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 
于 2012-12-07T07:03:18.237 回答
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 
于 2012-12-07T07:04:09.567 回答