繁体   English   中英

“ on子句”中的未知列“ customer”

[英]Unknown column 'customer' in 'on clause'

我有一家公司的发票脚本,现在我对PHP有一点了解(尤其是处理现有文件),并且该脚本的程序员不再可用,因此我决定使用要约列表扩展该脚本。 它的工作原理与发票脚本完全相同,只是使用了不同的表。

现在我得到了错误:

发生数据库错误
错误编号:1054
“ on子句”中的未知列“ customer”

SELECT idofferte,noofferte,CONCAT(namecustomer,' ',lastname)
     customer,DATE_FORMAT(dateofferte,'%d/%m/%Y')dateofferte,
     (SELECT SUM(pu*duration)
         FROM service2
         WHERE offerte=idofferte
      ) subtotal,discount,btw,transport,material
FROM offerte
INNER JOIN customer ON idcustomer=customer
WHERE 1=1
ORDER BY CAST(SUBSTR(noofferte,9) AS UNSIGNED) DESC
LIMIT 0,25 

原始脚本(用于发票):

function ilist( $start = 0, $limit = 25, $pattern = '' ) {
    $where = 'WHERE 1=1';
    if( '' != $pattern )
        $where .= " AND namecustomer LIKE '$pattern%' OR lastname LIKE '$pattern%'";
    return $this->db->query( "SELECT idinvoice,noinvoice,CONCAT(namecustomer,' ',lastname) customer,DATE_FORMAT(dateinvoice,'%d/%m/%Y')dateinvoice,(SELECT SUM(pu*duration) FROM service WHERE invoice=idinvoice)subtotal,discount,btw,transport,material FROM invoice INNER JOIN customer ON idcustomer=customer $where ORDER BY CAST(SUBSTR(noinvoice,9) AS UNSIGNED) DESC LIMIT $start,$limit" )->result_array();
} 

我的脚本(要约):

function ilist( $start = 0, $limit = 25, $pattern = '' ) {
    $where = 'WHERE 1=1';
    if( '' != $pattern )
        $where .= " AND namecustomer LIKE '$pattern%' OR lastname LIKE '$pattern%'";
    return $this->db->query( "SELECT idofferte,noofferte,CONCAT(namecustomer,' ',lastname) customer,DATE_FORMAT(dateofferte,'%d/%m/%Y')dateofferte,(SELECT SUM(pu*duration) FROM service2 WHERE offerte=idofferte)subtotal,discount,btw,transport,material FROM offerte INNER JOIN customer ON idcustomer=customer $where ORDER BY CAST(SUBSTR(noofferte,9) AS UNSIGNED) DESC LIMIT $start,$limit" )->result_array();
} 

我的脚本和原始脚本之间的区别在于表格。 我该如何解决这个错误?

注意:该错误不会出现在课程的原始脚本中。

提前致谢!

编辑:表:

-------------------------------
Invoice
-------------------------------
idinvoice
noinvoice
costumer
dateinvoice
discount
btw
transport
material
employee
creation

-------------------------------
Offerte
-------------------------------
idofferte
noofferte
customer
dateofferte
subjectofferte
discount
btw
transport
material
employee
creation

-------------------------------
customer
-------------------------------
idcustomer
namecustomer
lastname
address
number
zip
city
phone
email

-------------------------------
service
-------------------------------
idservice
dateservice
description
duration
pu
invoice

-------------------------------
service2
-------------------------------
idservice
dateservice
description
duration
pu
offerte

有问题了。 我刚刚意识到我在数据库中打错了字。 我写为列名:Costumer而不是客户。

谢谢大家的帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM