剥掉外层后改题
我正在使用 MySQL 5.1
select s.status, street, m.meterpointid
from meterpoint m inner join account a
on ( m.accountid = a.accountid) inner join
meterservice s
on ( m.meterpointid = s.meterpointid )
where a.citystateid=1 and m.meterpointid=3008 and m.lastupdate is not null
group by status, street ;
上面的查询返回
1 210 S HWY 3 3008
select s.status, street, m.meterpointid
from meterpoint m inner join account a
on ( m.accountid = a.accountid) inner join
meterservice s
on ( m.meterpointid = s.meterpointid )
where a.citystateid=1 and m.lastupdate is not null
group by status, street ;
但上面查询的输出与之前没有 m.meterpointid=3008
的查询完全相同,但不包含 1 210 S HWY 3 3008
有什么想法吗?
谢谢 那仁
最佳答案
内部查询的更改正在更改外部查询中的计数,因此 having count(*) = 1
不再为真。我发现诊断这类事情的最佳方法是剥离外层并查看内部查询,直到我弄清楚发生了什么。
关于mysql - 查询是否返回一致的结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13711350/