簡體   English   中英

MYSQL-錯誤代碼:-1241“運算符應包含1列”

[英]MYSQL - Error Code :- 1241 “Operand should contain 1 column(s) ”

我正在做一個項目。
我有以下查詢

select sid, reading, (
    select customer_id as cid, sub_location_id as location_id
    from customer_information  where sub_location_id = 1)
    from customer_consumption 
where customer_consumption.customer_id = customer_information.customer_id 
and month(bill_date) = month(now())

幫忙

您似乎想要顯式聯接:

select cc.sid, cc.reading, 
       ci.customer_id as cid, ci.sub_location_id as location_id
from customer_consumption cc join
     customer_information ci
     on cc.customer_id = ci.customer_id 
where month(bill_date) = month(now()) and ci.sub_location_id = 1;

您的原始語法非常不合常規。 您似乎需要了解有關如何使用SQL的更多信息。

暫無
暫無

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

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