繁体   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