数据库里面有两个字段的位置不对,要把他们对调换下。因为没有数据库写的权限,需要用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

mysql 更新sql报错:You can't specify target table 'wms_cabinet_form' for update in FROM clause的更多相关文章

  1. mysql 报错You can't specify target table 'wms_cabinet_form' for update in FROM clause

    这个错误是说从t表select出来的无法又更新t表. 可以在select的时候先取个别名,弄个临时表即可.

  2. mysql的一个特殊问题 you can't specify target table 'cpn_regist' for update in FROM clause

    今天在操作数据库的时候遇到了一个问题,sql语句如下: UPDATE cpn_yogurt_registration SET dep1Name = '1' WHERE `key` in  (SELEC ...

  3. mysql更新表数据时报错 You can't specify target table 'RES_CATALOG_CLASSIFY' for update in FROM clause

    You can't specify target table for update in FROM clause含义:不能在同一表中查询的数据作为同一表的更新数据. 将sql语句 UPDATE RES ...

  4. Mysql -- You can't specify target table 'address' for update in FROM clause

    做地址管理时,需要先根据要设为默认的地址的用户将用户的其他地址都设置为非默认 需要select出用户id然后update 原语句 update address set isdeafult = 0 wh ...

  5. Mysql update in报错 [Err] 1093 - You can't specify target table 'company_info' for update in FROM clause

    Mysql update in报错 解决方案: [Err] 1093 - You can't specify target table 'company_info' for update in FRO ...

  6. mysql uodate 报错 You can't specify target table '**' for update in FROM clause

    You can't specify target table 'sc' for update in FROM clause 背景:把“sc”表中“叶平”老师教的课的成绩都更改为此课程的平均成绩: 上面 ...

  7. mysql中更新或者删除语句中子语句不能操作同一个表You can't specify target table 'test' for update in FROM clause

    问题描述:有个数据表test,有个字段value,如下 mysql> select * from test;+----+------------------------------------+ ...

  8. 关于mysql 5.7版本“报[Err] 1093 - You can't specify target table 'XXX' for update in FROM clause”错误的bug

    不同于oracle和sqlserver,mysql并不支持在更新某个表的数据时又查询了它,而查询的数据又做了更新的条件,因此我们需要使用如下的语句绕过: , notice_code ) a) ; 本地 ...

  9. mysql中【update/Delete】update中无法用基于被更新表的子查询,You can't specify target table 'test1' for update in FROM clause.

    关键词:mysql update,mysql delete update中无法用基于被更新表的子查询,You can't specify target table 'test1' for update ...

随机推荐

  1. Android调用 .Net Core WebApi 返回数据,用FastJSON解析一直报错。

    问题描述:.Net Core WebApi中用Newtonsoft.Json 把datatable转成json字符串,如:JsonConvert.SerializeObject(table,Forma ...

  2. ImportError: No module named 'tkinter'

    环境说明: windows7.vscode1.33.1.python3.7.0. 解决方案: 通过安装程序单独卸载“tcl/tk and IDLE”------重新安装“tcl/tk and IDLE ...

  3. proxy写监听方法,实现响应式

    var data = { price: 5, quantity: 2 };var data_without_proxy = data; // 保存源对象data = new Proxy(data_wi ...

  4. Linux定时增量更新文件--转

    http://my.oschina.net/immk/blog/193926 动机与需求:现在有两台服务器A和B,由于A的存储随时会挂(某些原因),所以需要B机器上有A的备份,并且能够与A同步更新 一 ...

  5. 深入理解JavaScript系列(42):设计模式之原型模式

    介绍 原型模式(prototype)是指用原型实例指向创建对象的种类,并且通过拷贝这些原型创建新的对象. 正文 对于原型模式,我们可以利用JavaScript特有的原型继承特性去创建对象的方式,也就是 ...

  6. Firebird 用查询结果集更新数据,merge

    Merge语法: MERGE INTO target [[AS] target-alias ] USING source [[AS] source-alias ] ON join-condition ...

  7. [转]Add Bootstrap Glyphicon to Input Box

    本文转自:http://stackoverflow.com/questions/18838964/add-bootstrap-glyphicon-to-input-box How can I add ...

  8. 如何查找消耗资源较大的SQL

    对于优化来讲,查找消耗资源较大的SQL至关重要,下面介绍几个之前用到的SQL. 1.从V$SQLAREA中查询最占用资源的查询. select b.username username,a.disk_r ...

  9. Layer UI 模块化的用法(转)

    此文章适合入门的同学查看,之前因为项目的原因,在网上找了一套Layer UI做的后台管理系统模板,完全不懂LayUI里面的JS用法,看了官方文档和其它资料后才明白怎么去实现模块化这个例子,但是还是感觉 ...

  10. 项目开发-->高级功能汇总

    祭奠曾经逝去的青春…… 1.高级功能汇总-->Memcached之ASP.NET实现 2.高级功能汇总-->HubbleDotNet软件安装