在这个例子中如何使用mysql中的innerjoin进行更新?

时间:2018-02-15 07:41:56

标签: mysql

我想更新此示例但不成功。

**示例:**

select * 
from 
(select * 
from
(select * from 
 table1 tbl1
inner join table2 tbl2
on tbl1.id=tbl2.cid
inner join (select * from table3 where id>3)  tbl3
on tbl3.id=tbl1.id)td1
inner join table4 tbl4
on td1.id=tbl4.id)td2
inner join table5 tbl5
on tbl5.name=td2.des
where tbl5.name is not null

现在,我想要使用name.tbl5更新列des.tbl1。 与没有innerjoin并创建td2的tbl1和tbl5无关。 清楚了吗?

update table1 tbl1
from 
    (select * 
    from
    (select * from 
     table1 tbl1
    inner join table2 tbl2
    on tbl1.id=tbl2.cid
    inner join (select * from table3 where id>3)  tbl3
    on tbl3.id=tbl1.id)td1
    inner join table4 tbl4
    on td1.id=tbl4.id)td2
    inner join table5 tbl5
    on tbl5.name=td2.des

set des.tbl1=name.tbl5
    where tbl5.name is not null

0 个答案:

没有答案