Christopher Lyon wrote:
> Not sure if I should post this to beginners or not but there it goes.
> 
> I have 10+ tables with some of the same information in each in table
> of a mysql database. Here is an example: 
> 
[snip]
>
> I need to take the names and add the counts up for between each table
> and I am not sure how to make that happen. I would be able to do a
> select query so that the values are all in one query, like this:  
>
[snip]

A UNION query is the standard SQL way to approach this kind of thing. I
don't know MySQL, so I don't know if it supports UNION.

   select name, sum(count) from
   (
       select name, count from table_a
       union all select name, count from table_b
       union all select name, count from table_c
   )
   group by name

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to