First, get a book on SQL. Read about joins in SELECT statements.
Then, if you still need a quick answer, try the following:
INSERT INTO table_c(name, score)
SELECT name, a.score - b.score
FROM table_a a
LEFT JOIN table_b b ON b.name = a.name;
Hope that helps.
G'luck,
Peter
--
No language can express every thought unambiguously, least of all this one.
On Tue, Apr 10, 2001 at 03:57:54PM +0545, Deependra B. Tandukar wrote:
> Greetings!
>
> I am using MySQL in RedHat 6.2 with PHP 4.0. I have a question on MySQL. Suppose I
>have two tables A and B in my database:
> Table A
> Name Score
> a 45
> b 20
> c 75
> d 55
>
> Table B
> Name Score
> a 20
> b 9
> c 25
>
> Now I need to subtract values of table B from table A and result should be
> like:
> Table C
> Name Score
> a 25
> b 11
> c 50
> d 55
>
> How can I do this?
>
> Looking forward to hearing from you.
---------------------------------------------------------------------
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