mysql 更新sql报错:You can't specify target table 'wms_cabinet_form' for update in FROM clause
数据库里面有两个字段的位置不对,要把他们对调换下。因为没有数据库写的权限,需要用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的更多相关文章
- mysql 报错You can't specify target table 'wms_cabinet_form' for update in FROM clause
这个错误是说从t表select出来的无法又更新t表. 可以在select的时候先取个别名,弄个临时表即可.
- 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 ...
- 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 ...
- Mysql -- You can't specify target table 'address' for update in FROM clause
做地址管理时,需要先根据要设为默认的地址的用户将用户的其他地址都设置为非默认 需要select出用户id然后update 原语句 update address set isdeafult = 0 wh ...
- 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 ...
- 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”表中“叶平”老师教的课的成绩都更改为此课程的平均成绩: 上面 ...
- mysql中更新或者删除语句中子语句不能操作同一个表You can't specify target table 'test' for update in FROM clause
问题描述:有个数据表test,有个字段value,如下 mysql> select * from test;+----+------------------------------------+ ...
- 关于mysql 5.7版本“报[Err] 1093 - You can't specify target table 'XXX' for update in FROM clause”错误的bug
不同于oracle和sqlserver,mysql并不支持在更新某个表的数据时又查询了它,而查询的数据又做了更新的条件,因此我们需要使用如下的语句绕过: , notice_code ) a) ; 本地 ...
- 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 ...
随机推荐
- Flutter 实现退出登录功能,应用退出到登录界面 | 返回应用首页
1. 使用场景:退出登录./// 路由作用:移除 [ModalRoute.withName("/loginPage")] 除外的所有界面,并跳转到 ["/loginPag ...
- 论文阅读 | Region Proposal by Guided Anchoring
论文阅读 | Region Proposal by Guided Anchoring 相关链接 论文地址:https://arxiv.org/abs/1901.03278 概述 众所周知,anchor ...
- Python——爬取百度百科关键词1000个相关网页
Python简单爬虫——爬取百度百科关键词1000个相关网页——标题和简介 网站爬虫由浅入深:慢慢来 分析: 链接的URL分析: 数据格式: 爬虫基本架构模型: 本爬虫架构: 源代码: # codin ...
- Leo-io 的C语言实现简单五子棋游戏观后感
源代码: /************************************************************** ** 文 件 名:wuziqi.cpp ** 功 能:扫 ...
- docker 把容器commit成镜像
该方法是使用docker commit 命令,其命令格式为: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]] 主要参数选项包括: -a ,– ...
- Kubernetes Device Plugins
The gRPC server that the device plugin must implement is expected to be advertised on a unix socket ...
- 如何在Firebug中修改js变量的值
在做项目的时候,经常需要调试js,要是项目环境在本地,可以直接在js代码里面设置断点或者修改变量值.但是在测试或者生产等线上环境时,再频繁登录服务器去修改js代码就显得麻烦了.项目线上环境,可以在fi ...
- Helper Devise: could not find the `Warden::Proxy` instance on request environment
在使用devise这个gem时,编写控制器层的单元测试,你需要在你的rspec帮助文件 rails_helper.rb里添加下面这一样 RSpec.configure do |config| conf ...
- Lvmetad is not active yet错误处理
Lvmetad is not active yet错误处理 问题现象 今天早上把之前的服务器关机换了一个位置,之后启动后出现错误信息: lvmetad is not active yet; using ...
- restful api理解
REST -- REpresentational State Transfer 直接翻译:表现层状态转移. 首先要明确一点:REST 实际上只是一种设计风格,它并不是标准. 0. REST不是&quo ...