簡體   English   中英

MySQL on子句中的未知列

[英]Unknown column in on clause MySQL

我想訪問MySQL子查詢中的字段,但是'var_customer_id' in 'on clause'錯誤中得到了未知列'var_customer_id' in 'on clause' 這是我的代碼:

SELECT *,
        CONCAT(customer_phone_1, ', ', customer_phone_2) AS customer_phone,
        CONCAT(customer_fax_1, ', ', customer_fax_2) AS customer_fax,
        CONCAT(customer_email_1, ', ', customer_email_2) AS customer_email,
        tbl_customer.customer_id AS var_customer_id,                
        (
            SELECT
                GROUP_CONCAT(tbl_service.service_name SEPARATOR ', ')
            FROM
                kuesioner_bbia.tbl_customer_service
                INNER JOIN kuesioner_bbia.tbl_service 
                ON (tbl_customer_service.service_id = tbl_service.service_id )
                AND tbl_customer_service.customer_id=var_customer_id                    
            GROUP BY tbl_customer_service.customer_id                   
            )               

        FROM tbl_customer
        ORDER BY customer_id ASC

那么如何解決呢? 對不起我的英語不好。

錯誤在這里:

ON (tbl_customer_service.service_id = tbl_service.service_id )
                AND tbl_customer_service.customer_id=var_customer_id   

可以是以下任意一種(注意:我用var_customer_id替換了tbl_customer.customer_id ):

ON (tbl_customer_service.service_id = tbl_service.service_id )
WHERE tbl_customer_service.customer_id = tbl_customer.customer_id

或(重新定位右括號):

ON (tbl_customer_service.service_id = tbl_service.service_id 
AND tbl_customer_service.customer_id = tbl_customer.customer_id)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM