MYSQL - 错误代码: - 1241“操作数应包含1列”

时间:2014-06-13 11:10:00

标签: php mysql sql

我正在开展一个项目 我有以下查询

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())

帮助解决这个问题

1 个答案:

答案 0 :(得分:2)

您似乎想要一个明确的联接:

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的更多信息。