Updating across tables

From: Christopher Stephens (Christopher.Stephens@computing-services.oxford.ac.uk)
Date: Mon Oct 18 1999 - 19:30:34 EST


Hi,

This is probably a dumb question, but...

Say I have two tables PEOPLE and WORKS

PEOPLE
+--------+---------+
|surname | char(50)|
|forename| char(50)|
|UID | int |
+--------+---------+

WORKS
+--------+----------+
|UID2 | int |
|name |char(100) |
|title |char(100) |
+--------+----------+

PEOPLE.UID has a different value for each surname and each surname occurs
only once in the PEOPLE table.
WORKS.name is made up of the surname and forename from the PEOPLE table and
the same name can occur a number of times. What I want to do is to set
WORKS.UID2 = PEOPLE.UID where the names match. More generally I wonder if
there is a way to update a table based on results pulled from a different
table. I have tried sending another query from within a while (@row =
$sth->fetchrow()) loop, but this only gives me a error.

I am working with version 2.0.7 on Solaris-2.7-Sparc using msql_DBI and
Perl 5.00404

Any tips greatly appreciated.

tia

Chris
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Information is not knowledge...." | Chris Stephens
                                      | Humanities Computing Unit
 +44 1865 283 295 | OUCS
  http://www.hcu.ox.ac.uk/ | Oxford OX2 6NN
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-------------------------------------------------------------------------
To unsubscribe, go to http://www.Hughes.com.au/extras/email/



This archive was generated by hypermail 2b30 : Mon Mar 04 2002 - 09:03:51 EST