Update with data from table creates random input
Update with data from table creates random input
От:
Randall Perry <rgp@systame.com>
Дата:
I've got the following query which imports address data from one table into
another based on the value of the primary key, cust_no.
This query is successful, but the imported rows DO NOT MATCH the primary key
of the updated table.
I've checked the 2nd table to make sure the key values and addresses match,
and they do.
So, if cust_no 1 is supposed to be Miami, FL, it's becoming Flint, MI. The
rows are correct, the address, city, state, zip is right for each record,
it's just getting imported to the wrong cust_no.
What gives?
update cust2
set address = cust_temp.address,
address2 = cust_temp.address2,
city = cust_temp.city,
state = cust_temp.state,
zip = cust_temp.zip
from cust_temp
where cust2.cust_no = cust_temp.cust_no;
--
Randy Perry
sysTame
Mac Consulting/Sales
phn 772.589.6449
mobile email help@systame.com
Re: Update with data from table creates random input
От:
Randall Perry <rgp@systame.com>
Дата:
WHOOPS! Never mind. I discovered there were some extra rows with bad data in the cust_temp table. > I've got the following query which imports address data from one table into > another based on the value of the primary key, cust_no. > > This query is successful, but the imported rows DO NOT MATCH the primary key > of the updated table. > > I've checked the 2nd table to make sure the key values and addresses match, > and they do. > > So, if cust_no 1 is supposed to be Miami, FL, it's becoming Flint, MI. The > rows are correct, the address, city, state, zip is right for each record, > it's just getting imported to the wrong cust_no. > > What gives? > > > > update cust2 > set address = cust_temp.address, > address2 = cust_temp.address2, > city = cust_temp.city, > state = cust_temp.state, > zip = cust_temp.zip > from cust_temp > where cust2.cust_no = cust_temp.cust_no; > -- Randy Perry sysTame Mac Consulting/Sales phn 772.589.6449 mobile email help@systame.com