Oracle Multiple Table Association UPDATE statement

Source: Internet
Author: User

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
)

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.