Oracle Multiple Table Association UPDATE statement
1 The simplest form of SQL code
--confirmed that all customer_id less than 1000 of the Customers table are ' Beijing '
Within the--1000 are the company to the country before the old customers in the city:
Update customers
set city_name= ' Beijing '
where customer_id<1000
2 Two tables (multiple tables) association update--only the connection SQL code in the WHERE clause
-This time the extracted data are VIP and include new, so conveniently update customer category
Update customers A--use alias
set customer_type= ' 01 '--01 for vip,00 as normal
1 from
tmp_cust_city b
where b.customer_id=a.customer_id
)
3 Two tables (multiple tables) association update--modified value by another table operation to SQL code
Update customers A--use alias
set City_name= (select B.city_name from tmp_cust_city b where b.customer_id=a.customer_id) c1/>1from
tmp_cust_city b
where b.customer_id=a.customer_id
)
--update more than 2 values
update Customers A-use alias
set (City_name,customer_type) = (select B.city_name,b.customer_type from
tmp_cust_city b
where b.customer_id=a.customer_id)
1
From Tmp_cust_city b
where b.customer_id=a.customer_id
)