mysql中的一个特殊问题:You can’t specify target table ‘abc’ for update in FROM clause
来源:互联网 发布:大数据是考研什么专业 编辑:程序博客网 时间:2024/05/21 18:00
今天在处理数据的时候,需要update医院的行政编码。在医院
(hospital)表,医院所在地一般记做“海淀,东城”,而在行政区码
(codenum)中,却是“海淀区,东城区”
为了解决这个问题,首先使用了Mysql
中的CONCAT
函数。
SELECT hospital.district FROM hospital, codename WHERE codename.`name` IN( SELECT CONCAT(district,"区") FROM hospital)
得到
当我以为剩下的工作,用如下的updata语句就可以解决的时候,
UPDATE hospital, codenameSET hospital.qu=codename.numWHERE hospital.qu IN(SELECT hospital.district FROM hospital, codename WHERE codename.`name` IN( SELECT CONCAT(district,'区') FROM hospital))
却报错了:You can't specify target table 'hospital' for update in FROM clause
意思应该就是,你要update一个表的时候,不能让这个表出现在FROM
里面(应该是会导致死循环思密达)。
解决方法也很愚蠢,新建一个tmp
表。然后用这个表进行UPDATE
CREATE TABLE tmp ASSELECT hospital.district, codename.num FROM hospital, codename WHERE codename.`name` IN( SELECT CONCAT(district,'区') FROM hospital)
0 0
- mysql中的一个特殊问题:You can’t specify target table ‘abc’ for update in FROM clause
- mysql 一个较特殊的问题: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
- mysql 一个较特殊的问题:You can't specify target table 'wms_cabinet_form' for update in FROM clause
- mysql 一个较特殊的问题:You can't specify target table '表名' for update in FROM clause
- mysql update语句问题:You can't specify target table 'user' for update in FROM clause
- mysql问题:You can't specify target table for update in FROM clause
- MYSQL问题:You can't specify target table '表名' for update in FROM clause
- mysql You can't specify target table for update in FROM clause异常问题.
- MySql报错: You can't specify target table 'table name' for update in FROM clause
- 【MySQL】1093 You can't specify target table 'table name' for update in FROM clause
- Mysql - You can't specify target table 'dataproduct' for update in FROM clause
- MySQL报错“ you can't specify the target table for ‘update’ in from clause”
- mysql中You can't specify target table for update in FROM clause错误
- MYSQL 临时表 #1093 - You can't specify target table 'dealer_admin' for update in FROM clause
- MySQL "You can't specify target table 'X' for update in FROM clause" 错误解决方法
- Mysql 错误 Code: 1093. You can't specify target table for update in FROM clause
- mysql中You can't specify target table for update in FROM clause错误
- 【iOS】UIViewController、UINavigationController与UITabBarController的整合使用
- Dungeon Game
- nginx对keepalive和pipeline请求处理分析
- 逻辑思维 代码人生 程序员必看的十大经典电影~!
- 情商高的人什么表现?
- mysql中的一个特殊问题:You can’t specify target table ‘abc’ for update in FROM clause
- mysqldump备份还原和mysqldump导入导出语句大全详解
- The Genome Reference Consortium Human Genome Build 37 now Available(GRCh37)
- 内核抢占
- linux如何匹配tab
- [JavaScript]项目优化总结
- C++编程
- 【matlab】快捷方式
- java中静态代码块的用法 static用法详解