Oracle Multi-Table Association UPDATE statement

Source: Internet
Author: User

1) The simplest form

SQL Code

--confirmed that all customer_id less than 1000 of the Customers table are ' Beijing '

--1000 within the company to the country before the old customers of the city:) update customersset city_name= ' Beijing ' where customer_id<1000

2) Two tables (multiple tables) associated update--only in the WHERE clause of the connection

SQL Code
--This time the extracted data are VIP and include new, so update the customer category updates customers A--using the alias set customer_type= ' 01 '--01 for vip,00 for normal where exists (select 1from tmp_cust_city bwhere b.customer_id=a.customer_id)

3) Two tables (multiple tables) associated update--the modified value is calculated by another table

SQL Code
Update customers A--using alias set City_name= (select B.city_name from tmp_cust_city b where b.customer_id=a.customer_id) where E Xists (select 1from tmp_cust_city bwhere b.customer_id=a.customer_id)--update more than 2 values update customers A--using alias set (City_na Me,customer_type) = (select B.city_name,b.customer_typefrom tmp_cust_city bwhere b.customer_id=a.customer_id) where Exists (select 1from tmp_cust_city bwhere b.customer_id=a.customer_id)

Oracle Multi-Table Association UPDATE statement

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.