John,
Tuesday, November 05, 2002, 1:50:32 AM, you wrote:
JJ> I have a callers table and a citylist table. Both tables have a field
JJ> 'town' and both tables have a field called 'zipcode'.
JJ> The citylist is a list of cities and their zip codes.
JJ> citylist.city and citylist.zipcode
JJ> The callers table has the same 2 field names, but the zip code field is
JJ> empty.
JJ> How can I populate the callers.zipcode field by looking up the the zip
JJ> code in the cities table?
JJ> I know how to do simple selects and simple updates, but I do no know how
JJ> to match the callers.town with the cities.town, and then make
JJ> callers.zipcode equal the zipcode for the callers.town=cities.town match.
John, multi-table updates is supported since 4.0.2. So, if you use
MySQL server 4.0.2 or high you can just do:
UPDATE callers, cities
SET callers.zipcode=cities.zipcode
WHERE callers.town=cities.town;
Otherwise you can do it with programming language or like describen for
DELETE here:
http://www.mysql.com/doc/en/ANSI_diff_Sub-selects.html
--
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Victoria Reznichenko
/ /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED]
/_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net
<___/ www.mysql.com
---------------------------------------------------------------------
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