2011-09-19 48 views
0

我不明白爲什麼在小組發言列「RECNO」不明確爲什麼我得到[ERR] 1052 - 組發言列「RECNO」不明確(MySQL的)

[SQL] SELECT `d`.`FATURA_DURUM` AS `FATURA_DURUM`, 
     `i`.`RECNO` AS `RECNO`, 
     `i`.`BOLGE` AS `BOLGE`, 
     `m`.`MUSTERI_UNVANI` AS `MUSTERI_UNVANI`, 
     `i`.`MUSTERI_NO` AS `MUSTERI_NO`, 
     `i`.`HAKEDIS_ONAY_PERSONEL` AS `HAKEDIS_ONAY_PERSONEL`, 
     `i`.`ISEMRI_NO` AS `ISEMRI_NO`, 
     `s`.`ADRES_EMAIL` AS `ADRES_EMAIL`, 
     `i`.`RECNO` AS `ISEMRI_RECNO`, 
     `i`.`SERVIS_BAS_TAR` AS `SERVIS_BAS_TAR`, 
     `i`.`SERVIS_BIT_TAR` AS `SERVIS_BIT_TAR`, 
     `i`.`URUN_CIHAZ_ADI` AS `URUN_CIHAZ_ADI`, 
     `i`.`URUN_MARKA_ADI` AS `URUN_MARKA_ADI`, 
     `i`.`URUN_MODEL_ADI` AS `URUN_MODEL_ADI`, 
     `i`.`ONAY_DURUM` AS `ONAY_DURUM`, 
     `i`.`HAKEDIS_DURUM` AS `HAKEDIS_DURUM`, 
     `i`.`HAKEDIS_FATURANO` AS `HAKEDIS_FATURANO`, 
     `i`.`URUN_SERI_NO` AS `URUN_SERI_NO`, 
     `s`.`FIRMA_UNVANI` AS `FIRMA_UNVANI`, 
     `i`.`YAPILANLAR_M` AS `YAPILANLAR`, 
     st.serino_count 
FROM (((`isemri` `i` 
     left join `musteri_tan` `m` on ((`i`.`MUSTERI_RECNO` = `m`.`RECNO`))) 
     join `isemri_det` `d` on ((`i`.`RECNO` = `d`.`ISEMRI_RECNO`))) 
     join `servisler` `s` on ((`i`.`BOLGE` = `s`.`BOLGE_NO`))) 
     left join 
     (select URUN_SERI_NO as URUN_SERI_NO2, count(*) as serino_count from ISEMRI 
     group by URUN_SERI_NO) as st on (st.URUN_SERI_NO2 = i.URUN_SERI_NO) WHERE 1 = 1 and `i`.HAKEDIS_DURUM=0 and `i`.ONAY_DURUM != 1 and (`i`.SERVIS_BAS_TAR between '2011-02-01 00:00:00' and '2011-09-19 23:59:59') and `i`.BOLGE=710 group by `i`.`RECNO`, 
     `m`.`MUSTERI_UNVANI`, 
     `i`.`MUSTERI_NO`, 
     `i`.`ISEMRI_NO`, 
     `i`.`SERVIS_BAS_TAR`, 
     `i`.`SERVIS_BIT_TAR`, 
     `i`.`URUN_CIHAZ_ADI`, 
     `i`.`URUN_MARKA_ADI`, 
     `i`.`URUN_MODEL_ADI`, 
     `i`.`ONAY_DURUM`, 
     `i`.`HAKEDIS_DURUM`, 
     `i`.`HAKEDIS_FATURANO` 
    and ((FATURA_DURUM LIKE '%ayten%' OR RECNO LIKE '%ayten%' OR FIRMA_UNVANI LIKE '%ayten%' OR MUSTERI_UNVANI LIKE '%ayten%' OR SERVIS_BAS_TAR LIKE '%ayten%' OR SERVIS_BIT_TAR LIKE '%ayten%' OR URUN_CIHAZ_ADI LIKE '%ayten%' OR URUN_MARKA_ADI LIKE '%ayten%' OR URUN_MODEL_ADI LIKE '%ayten%' OR ONAY_DURUM LIKE '%ayten%' OR HAKEDIS_DURUM LIKE '%ayten%' OR serino_count LIKE '%ayten%' OR HAKEDIS_FATURANO LIKE '%ayten%' OR URUN_SERI_NO LIKE '%ayten%' OR YAPILANLAR LIKE '%ayten%')) order by `i`.RECNO desc 

[Err] 1052 - Column 'RECNO' in group statement is ambiguous 

編輯:以上代碼來自Navicat。下面是從PHP錯誤:

<br /> 
<b>Fatal error</b>: Uncaught exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'RECNO' in group statement is ambiguous' in D:\Programs\xampp\htdocs\www\app\httpdocs\Application\System\Library\Zend\Db\Statement\Pdo.php:238 
Stack trace: 
#0 D:\Programs\xampp\htdocs\www\app\httpdocs\Application\System\Library\Zend\Db\Statement.php(283): Zend_Db_Statement_Pdo-&gt;_execute(Array) 
#1 D:\Programs\xampp\htdocs\www\app\httpdocs\Application\System\Library\Zend\Db\Adapter\Abstract.php(467): Zend_Db_Statement-&gt;execute(Array) 
#2 D:\Programs\xampp\htdocs\www\app\httpdocs\Application\System\Library\Zend\Db\Adapter\Pdo\Abstract.php(235): Zend_Db_Adapter_Abstract-&gt;query('SELECT `d`.`FAT...', Array) 
#3 D:\Programs\xampp\htdocs\www\app\httpdocs\Application\System\Library\DoDb.php(260): Zend_Db_Adapter_Pdo_Abstract-&gt;query('SELECT `d`.`FAT...') 
#4 D:\Programs\xampp\htdocs\www\app\httpdocs\Application\System\Library\DoDb.php(163): DoDb::printJsonDG('SELECT `d`.`FAT...', Object(Zend_Db_Adapt in <b>D:\Programs\xampp\htdocs\www\app\httpdocs\Application\System\Library\Zend\Db\Statement\Pdo.php</b> on line <b>238</b><br /> 
+2

您的主題與您的問題不符 –

+0

@a_horse_with_no_name,好的,我已編輯。 – ilhan

回答

3

您遇到「RECNO」在您的查詢的出現而不在它前面的表的別名。

看到您的查詢中有多個表(例如m和i),其中包含RECNO字段;可能是後來的RECNO(我在最後看到一個,並且在那裏放置OR RECNO LIKE '%ayten%';這可能需要其中一個別名)

在任何時候在每個字段的前面使用別名可能是一個好習慣;避免這些錯誤,並且您可以輕鬆地看到字段來自哪裏:)。

相關問題