多表关联 update

UPDATE t_invests
INNER JOIN t_user_coupons ON t_invests.user_coupon_id = t_user_coupons.id
SET t_invests.virtual_product_id = t_user_coupons.virtual_product_id
WHERE
    t_user_coupons.virtual_product_id > 0;
时间: 2024-07-29 04:52:43

多表关联 update的相关文章

ORACLE多表关联UPDATE 语句

1) 最简单的形式 SQL 代码 --经确认customers表中所有customer_id小于1000均为'北京' --1000以内的均是公司走向全国之前的本城市的老客户:) update customers set city_name='北京' where customer_id<1000 2) 两表(多表)关联update -- 仅在where字句中的连接 SQL 代码 --这次提取的数据都是VIP,且包括新增的,所以顺便更新客户类别 update customers a -- 使用别名

两表(多表)关联update的写法 .

原文:两表(多表)关联update的写法 . 关于两表关联的update,可以把SQL写成了在SQL Server下面的特有形式,但是这种语法在Oracle下面是行不通的 update customers a    set    city_name=(select b.city_name from tmp_cust_city b where b.customer_id=a.customer_id)   where  exists (select 1                   from 

Oracle中如何实现Mysql的两表关联update操作

在看<MySQL 5.1参考手册>的时候,发现MySQL提供了一种两表关联update操作.原文如下: UPDATE items,month SET items.price=month.price WHERE items.id=month.id; 在MySQL中构造表验证了一下 mysql> select * from test; +------+--------+ | id | salary | +------+--------+ | 1 | 100 | | 2 | 200 | | 3

[转载] ORACLE 多表关联 UPDATE 语句

为了方便起见,建立了以下简单模型,和构造了部分测试数据:在某个业务受理子系统BSS中, SQL 代码 1 --客户资料表 2 create table customers 3 ( 4 customer_id number(8) not null, -- 客户标示 5 city_name varchar2(10) not null, -- 所在城市 6 customer_type char(2) not null, -- 客户类型 7 ... 8 ) 9 create unique index P

ORACLE 多表关联 UPDATE 语句

为了方便起见,建立了以下简单模型,和构造了部分测试数据:在某个业务受理子系统BSS中, SQL 代码 --客户资料表 create table customers ( customer_id number(8) not null, -- 客户标示 city_name varchar2(10) not null, -- 所在城市 customer_type char(2) not null, -- 客户类型 ... ) create unique index PK_customers on cus

oracle多表关联update

日常的开发中一般都是写的单表update语句,很少写多表关联的update. 不同于SQL Server,在Oracle中,update的多表连接更新和select的多表连接查询在使用的方法上存在较大差异. 语法比较难以说得清楚,直接上例子就妥了. update diosos_01 d1 set d1.name = ( select d2.name from diosos_02 d2 where d1.code = d2.code ) where d1.code is not null; 特别之

PL/SQL 多表关联UPDATE

假设有两个表A和B,A表字段a,b,c,d,B表字段b,e,f,两表的关联条件是字段b,现在想做个data patch,欲将B表中的字段e的值patch给A表的字段c. 有如下两种方法: 1 update A set A.c=(select e from B where B.b=A.b) where exists(select 1 from B where B.b=A.b); 2 merge into A using B on (A.b=B.b) when matched then update

oracle表关联update和表建立索引

update A a set a.A2 = (select b.B2 from B b where b.B1=a.A1) where exists (select 1 from B where B.B1=a.A1) -- Create/Recreate indexes create index t_source_phase_01 on t_source_phase (lineid)  tablespace COMMON_CABLE  pctfree 10  initrans 2  maxtran

Oracle Update 语句语法与性能分析 - 多表关联

Oracle Update 语句语法与性能分析 - 多表关联 为了方便起见,建立了以下简单模型,和构造了部分测试数据: 在某个业务受理子系统BSS中, SQL 代码 --客户资料表 create table customers ( customer_id number(8) not null, -- 客户标示 city_name varchar2(10) not null, -- 所在城市 customer_type char(2) not null, -- 客户类型 ... ) create