query from one table and insert result into another table

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ktell
Forum Newbie
Posts: 5
Joined: Fri Nov 29, 2002 1:12 am

query from one table and insert result into another table

Post by ktell »

Would appreciate help with the following php/mysql combination:
Trying to use the form variables submitted by user form to extract the correct state_pair_price from the state_pair table, example:
<? Select state_pair_price from state_pair where origin_state=$origin_state AND destination_state=$destination_state;

Next in the same script, I would like to insert the state_pair_price result from above into the field named price in a different table named email_quotes, example:
Insert state_pair_price into email_quotes.price;
?>

Both tables above reside in same database.

Any help would be appreciated.
Last edited by ktell on Fri Nov 29, 2002 1:32 am, edited 1 time in total.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you don't have to store the values locally, mysql can handle that internally (if you like ;) )
http://www.mysql.com/doc/en/INSERT_SELECT.html
Post Reply