I've got a query like this:
select a, b, c, group_concat(d separator ', ')
from t
group by a;
This seems to work just fine. As I understand it (forgive me, I'm a MySQL rookie!), it's returning rows of:
- each unique
a
value - for each
a
value, oneb
andc
value - also for each
a
value, all thed
values, concatenated into one string
This is what I want, but I also want to check that for each a
, the b
and c
are always the same, for all rows with that a
value.
My first thought is to compare:
select count(*) from t group by a, b, c;
with:
select count(*) from t group by a;
and make sure they're equal. But I've not convinced myself that this is correct, and I certainly am not sure there isn't a better way. Is there a SQL/MySQL idiom for this?
Thanks!