我在执行空洞查询时在mysql workbench中写了两个查询,我得到了相同的值。我该怎么办?
这是我的查询
Select *
from
(
(select division.name,
date(meter_data.reading_date),
sum(meter_data.meter_delta) 'Gas Consumption (m3)'
from meter, meter_data, division
where meter.meter_id = meter_data.meter_id
and meter.division_id = division.division_id
and Date(meter_data.reading_date) between '2018-04-01' and '2018-05-03'
group by date(meter_data.reading_date)
) as table1,
(Select Date(receipt.receipt_date),
sum(case receipt_item.item_name
when 'Gas' then receipt_item.item_amount else 0
end) 'Gas Purchase'
from receipt_item, receipt
where receipt.receipt_id = receipt_item.receipt_id
and Date(receipt.receipt_date) between '2018-04-01' and '2018-05-03'
group by Date(receipt.receipt_date)
) as table2
);
在单独执行查询时,每个查询返回精确的33个但总共返回1089个rwos
例如我在这里得到的所有重复的相同数据
答案 0 :(得分:0)
我的查询问题应该像beloow
}
这解决了我的问题