剥掉外层后改变了问题
我正在使用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
不再为true。我发现诊断这些问题的最佳方法是剥离外层并查看内部查询,直到我弄清楚发生了什么。
关于mysql - 查询返回的结果是否一致?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13711350/