Create a merge table of the year 2000 and year 2001 tables as follows. 
Then run your select on the merged table.
You can then drop the merge table if you don't need it anymore.


CREATE TABLE table3 (name, distance, date) TYPE=MERGE UNION=(table1,table2);
SELECT name, SUM(distance) FROM table3 GROUP BY name;
DROP table3;

HTH 
Edward


4/23/2001 5:01:48 PM, "Wix,Christian XCW" <[EMAIL PROTECTED]> wrote:

>Hi
>I have two similar tables. (table1 & table2). They contain the columns
>"name", "distance" and "date". Table1 is year 2000 and Table2 year 2001.
>
>I need to get the total distance for each name.
>For year 2000 I would do this:
>select name, SUM(distance) from table1 group by name;
>
>How do I do it for both years? (one query)
>
>Thanks,
>
>// Chris - Copenhagen
>
>
>---------------------------------------------------------------------
>Before posting, please check:
>   http://www.mysql.com/manual.php   (the manual)
>   http://lists.mysql.com/           (the list archive)
>
>To request this thread, e-mail <[EMAIL PROTECTED]>
>To unsubscribe, e-mail <[EMAIL PROTECTED]>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>
>




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to