Hi,

To this on I just see a solution, that depends on sub-selects, so it's 
available from Mysql 4.1 forward:

SELECT name,count(*) from ((SELECT name1 name FROM <tablename>) UNION ALL 
(SELECT name2 name FROM <tablename>) UNION ALL (SELECT name3 name FROM 
<tablename>)) tab GROUP by name;

Hope this solves you problem.

mpneves

On Thursday 19 January 2006 15:16, Critters wrote:
> Hi
> I have a table setup like this:
>
> id, name1, name2, name3
>
> Which has data like this:
>
> 1, Dave, Bob, Simon
> 2, Joe, Tim, Dave
> 3, Dave, Bob, Tom
>
> I can run
>
> SELECT name, count(id) FROM <tablename> GROUP BY name1 ORDER BY count(id)
> DESC
>
> Which would give me:
>
> Dave, 2
> Joe, 1
>
> But how would I go about getting the following result:
>
> Dave, 3
> Bob, 2
> Tom, 2
> Joe, 1
> Simon, 1
>
> Where it groups by name1, name2 and name3? Is it possible?
> -
> David Scott

-- 
AvidMind, Consultadoria Informática, Unipessoal, Lda.
Especialistas em OpenSource
http://www.avidmind.net
OBC2BIP

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to