Click to See Complete Forum and Search --> : Count occurances of name


green'n'white
07-15-2006, 10:22 AM
Hi,

using asp I have an access table with a number of colums ie, col1, col2, col3, which contain a number of randomly repeated names in each of the rows.

What i would like to do is return the number of times each name is present in all of the columns and present this in a table on my site,

i.e.

john - 2
dave - 3
etc

any help will be greatly appreciated,

chazzy
07-15-2006, 11:44 AM
select count(col1), col1 FROM your_table GROUP BY col1;

you would have to do that individually for each column though. unless access does views which i doub.t

aussie girl
07-16-2006, 02:23 AM
This works in MySQL, not sure about MS DB's

SELECT count(col1), count(col2), count(col3) FROM `tablename`
WHERE name = ' A name'

chazzy
07-16-2006, 09:58 PM
that should work, but i think he's saying the name value is in col1,col2 or col3.