tags:

views:

14

answers:

2

Is there a way to get a count of groups in mysql?

For example I have 4 rows

cat1 cat2 cat1 cat3

I would like a count of categories, i.e 3

Is this possible?

Thanks

A: 
select count(distinct(cat)) from table;
baton
Thanks for this, seems simple now.
Dave
A: 

Not sure if this is the "purest" answer, but you could do this with a nested select query

select count() from ( select catagory, count() from table_name group by catagory) A

Steve Sherry