I have some strange problem with one select.
Is it possible that the order in WHERE clause can influence the result?
Here is my select:
select u.userName, u.fullName, g.uuid as groupUuid, g.name as `group`,
m.number as module, count(distinct b.uuid) as buildCount, max(b.datetime),
count(distinct e.buildId) as errorBuildCount, e.id as errorId
from User u
inner join GROUP_USER GU on GU.user_id = u.id
inner join `Group` g on g.id = GU.group_id
inner join Course c on c.id = g.courseId
left outer join Build b on b.userId = u.id
left outer join Module m on m.id = b.moduleId
left outer join Error e on e.buildId = b.id
where c.uuid = 'HMUUcabR1S4GRTIwt3wWxzCO' and g.uuid = 'abcdefghijklmnopqrstuvwz'
group by u.userName,m.number,c.uuid, g.uuid
order by g.id asc, u.fullName asc, m.number asc
this will reproduce this result: http://dl.dropbox.com/u/4892450/sqlSelectProblem/select1.PNG
When I use this condition:
where g.uuid = 'abcdefghijklmnopqrstuvwz' and c.uuid = 'HMUUcabR1S4GRTIwt3wWxzCO'
(different order) I get a different result (see errorId column):
http://dl.dropbox.com/u/4892450/sqlSelectProblem/select2.PNG
Could you please help me? Is the whole select wrong, or can it be a mysql bug?