安装mysql时cabinet_mysql 更新sql报错:You can't specify target table 'wms_cabinet_form' for update in FROM c...

数据库里面有两个字段的位置不对,要把他们对调换下。因为没有数据库写的权限,需要用sql语句来实现。原来以为简单的

update table a set a.字段a=(select b字段 from table  where id=?) ,set a.字段b=(select a字段 from table where id=?) where id=? ,结果报了 这个问题

You can't specify target table 'wms_cabinet_form' for update in FROM clause

google 之后发现是mysql本身的问题,需要这样来写:

update  table set  字段a=(select t1.字段b from (select * from table where id=?)t1),set 字段b=(selet t2.字段a from (select * from table where id=?)t2) where id=?

自己的为例:

UPDATE ec_payment_type

SET return_url = (

SELECT

a.notify_url

FROM

(

SELECT

*

FROM

ec_payment_type

WHERE

payment_type_id = 10

) a

),

notify_url = (

SELECT

b.return_url

FROM

(

SELECT

*

FROM

ec_payment_type

WHERE

payment_type_id = 10

) b

)

WHERE

payment_type_id = 10

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值