为什么我确实收到 [ERR] 1052 - 列“RECNO” in group 语句不明确 (MySQL)

发布于 2024-12-05 04:18:41 字数 3827 浏览 1 评论 0原文

我无法理解为什么组语句中的列“RECNO”不明确

[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 />

I couldn't understand why Column 'RECNO' in group statement is ambiguous

[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

Edit: The above code is from Navicat. Here is the error from 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->_execute(Array)
#1 D:\Programs\xampp\htdocs\www\app\httpdocs\Application\System\Library\Zend\Db\Adapter\Abstract.php(467): Zend_Db_Statement->execute(Array)
#2 D:\Programs\xampp\htdocs\www\app\httpdocs\Application\System\Library\Zend\Db\Adapter\Pdo\Abstract.php(235): Zend_Db_Adapter_Abstract->query('SELECT `d`.`FAT...', Array)
#3 D:\Programs\xampp\htdocs\www\app\httpdocs\Application\System\Library\DoDb.php(260): Zend_Db_Adapter_Pdo_Abstract->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 />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风为裳 2024-12-12 04:18:41

您的查询中出现“RECNO”,前面没有表别名。

看到查询中有多个表(例如 m 和 i),其中包含字段 RECNO;可能是稍后的 RECNO (我在最后看到一个,并且您在其中放置 OR RECNO LIKE '%ayten%'; ,这可能需要这些别名之一。

使用别名可能是一个很好的做法始终位于每个字段的前面;它可以避免这些错误,并且您可以轻松查看字段的来源:)。

You're having an occurrence of "RECNO" in your query without a table alias in front of it.

Seeing there are multiple tables in your query (for instance m and i) that have the field RECNO in it; probably a later RECNO (I see one in the last and, where you put OR RECNO LIKE '%ayten%'; which might need one of those aliases.

It might be a good practice to use the aliases in front of every field at all times; it avoids these errors, and you can easily see where the fields come from :).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文