I am working on a project.
I have the following query
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())
You seem to want an explicit join:
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;
Your original syntax is highly unorthodox. You seem to need to learn more about how to use SQL.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.