表中出现重复数据,需要删除重复数据,只保留一条 DELETE FROM crm_participant WHERE id IN ( SELECT c.id cid FROM crm_participant c WHERE c.parentPhone IN ( SELECT a.parentPhone FROM crm_participant a GROUP BY a.parentPhone HAVING count( a.parentPhone ) > 1 ) AND c.id NOT IN (…
You can't specify target table for update in FROM clause含义:不能在同一表中查询的数据作为同一表的更新数据. 出现以上错误,是因为想将表自身的字段A的值作为被更新字段B的值而导致的. "自身更新自身"的正确写法: UPDATE t_loan SET f_biddingAmount = ( SELECT amount FROM( SELECT ln.*, ln.f_amount amount FROM t_loan ln ) lnn…
update语句中包含的子查询的表和update的表为同一张表时,报错:1093-You can’t specify target table for update in FROM clause mysql不允许update目标表和子查询里面的表为同一张表 错误sql:UPDATE mg_brand set `status`='0' where iID=(SELECT id from mg_industry where `name`='汽车') and id in (SELECT id from…
这句话意思是:不能先select再更新(修改)同一个表. 可以再外嵌套多一层,这个问题只有mysql有,mssql和oracle都没有. # 出错delete from Person where Id not in ( select min(Id) as Id from Person group by Email); # 正确delete from Person where Id not in ( select Id from ( select min(Id) as Id from Person…
使用mysql在删除表中重复记录 delete from user where username in (select user name form(select username from user group by username having count(username)>1)); 遇到mysql报错You can't specify target table for update in FROM clause 上网百度了下原来是mysql中不允许先select出同一表中的某些值,再u…
这篇文章主要介绍了mysql中You can't specify target table for update in FROM clause错误解决方法,需要的朋友可以参考下 MySQL中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中). 例如下面这个sql: 复制代码代码如下: delete from tbl where id in (  …
mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中). 例如下面这个sql: delete from tbl where id in ( select max(id) from tbl a where EXISTS ( )> ) group by tac ) 改写成下面就行了: delete from tbl where id in (…
在mysql执行下面语句时报错: You can’t specify target table for update in FROM clause UPDATE edu_grade_hgm_1 ' WHERE (outid, course_no) IN ( SELECT a.outid, a.course_no FROM edu_grade_hgm_1 a INNER JOIN edu_grade b ON a.outid = b.outid AND a.course_no = b.course…
mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中). 例①如下面这个sql: 代码如下: delete from tbl where id in  (         select max(id) from tbl a where EXISTS         (             select 1 from tbl b whe…
mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中). 例如下面这个sql: delete from tbl where id in ( select max(id) from tbl a where EXISTS ( ) ) group by tac ) 改写成下面就行了: delete from tbl where id in (…
mysql 一个较特殊的问题:You can't specify target table for update in FROM clause 即:不能先select出同一表中的某些值,再update这个表(在同一语句中),解决方案:查询时为表定义一个别名在取值 eg: UPDATE `EDMGR_FORM_BASICINFO` SET `EDMGR_FORM_BASICINFO`.`BELONG_DOMAIN` = '' WHERE `EDMGR_FORM_BASICINFO`.`C_TYPE…
MySQL出现You can’t specify target table for update in FROM clause 这个错误的意思是不能在同一个sql语句中,先select同一个表的某些值,然后再update这个表. 例如:message表保存了多个用户的消息 创建表 CREATE TABLE `message` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `uid` int(10) unsigned NOT NULL, `con…
mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中). 例如下面这个sql: 代码如下: delete from tbl where id in ( select max(id) from tbl a where EXISTS ( select 1 from tbl b where a.tac=b.tac group by tac HA…
将select出的结果再通过中间表select一遍,这样就规避了错误.注意,这个问题只出现于mysql,mssql和oracle不会出现此问题. mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中). later: But: Subquery returns more than 1 row表示子查询返回了多行数据 开始: delete…
mysql You can't specify target table for update in FROM clause解决方法出现这个错误的原因是不能在同一个sql语句中,先select同一个表的某些值,然后再update这个表. <pre>mysql> update message set content='Hello World' where id in(select min(id) from message group by uid);ERROR 1093 (HY000):…
mysql出现You can’t specify target table for update in FROM clause 这个错误的意思是不能在同一个sql语句中,先select同一个表的某些值,然后再update这个表. 例如:message表保存了多个用户的消息 创建表 CREATE TABLE `message` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `uid` int(10) unsigned NOT NULL, `con…
mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中) 例如 delete from table名称 where idStr in ( ) ); 就会报上面的错误 改 delete from table名称 where idStr in ( ) c from table名称 h group by h.otherKey ) s ); 通过中…
参考:http://www.jb51.net/article/60926.htm mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中). 将select出的结果再通过中间表select一遍,这样就规避了错误.注意,这个问题只出现于mysql,mssql和oracle不会出现此问题.…
翻译:MySQL不能指定更新的目标表在FROM子句 源SQL语句: delete from t_official_sys_user where USER_NAME IN(SELECT USER_NAME FROM t_official_sys_user b group by b.`USER_NAME` having  count(1) > 1) 执行报以下错误: [SQL] delete from t_official_sys_user where USER_NAME IN(SELECT USE…
mysql中You can't specify target table <tbl> for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中). 如下l: 需要将select出的结果再通过中间表select一遍,就可以规避了错误. 如下: PS:这个问题只出现于mysql,sql service 和 oracle 不会出现此问题.…
You can't specify target table 'sc' for update in FROM clause 背景:把“sc”表中“叶平”老师教的课的成绩都更改为此课程的平均成绩: 上面的sql是我写的,执行就报这个错,这个原因说的是 不能从自己表里查数据再更新自己 解决方法:嵌套一层中间表 update sc set sc.score = (select t1.score from (select avg(sc1.score) score from sc sc1 where sc…
mysql中You can't specify target table <tbl> for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中). 如下l: 需要将select出的结果再通过中间表select一遍,就可以规避了错误. 如下: PS:这个问题只出现于mysql,sql service 和 oracle 不会出现此问题.…
原SQL delete from DEP_SYSTEM_PORTLET_SETTINGS where ID in ( select ID from DEP_SYSTEM_PORTLET_SETTINGS ) 修改后 delete from DEP_SYSTEM_PORTLET_SETTINGS where ID in ( select ID from ( select ID from DEP_SYSTEM_PORTLET_SETTINGS ) C )…
UPDATE tbl SET col = ( SELECT ... FROM (SELECT.... FROM) AS x); 额外嵌套了一个 SELECT 语句 例如LeetCode 中的 Delete Duplicate Emails 正解: DELETE FROM Person WHERE id NOT IN ( SELECT id FROM ( SELECT min( id ) AS id FROM Person GROUP BY email ) AS m ); 错解: DELETE F…
有一个表示地区的表,表结构与数据大概如下表. ID NAME PARENT_ID 1 中国 2 广东省 1 3 广州市 2 4 荔湾区 3 5 越秀区 3 6 番禺区 3 7 小谷围街道 6 现为了查询方便,需要加一列PARENT_NAME,用以表示上级地区的名称(虽然不符合第三范式,传递依赖,但有时为了业务上的可行性.便利性,可以按实际情况考虑) ID NAME PARENT_ID PARENT_NAME 1 中国 2 广东省 1 3 广州市 2 4 荔湾区 3 5 越秀区 3 6 番禺区 3…
问题 You can't specify target table 'user_cut_record_0413' for update in FROM clause 原因 待更新/删除的数据集与查询的数据集撞车了,可以给后面的数据集加个别名,来解决撞车问题 报错语句 delete from user_cut_record_0413 where record_id IN ( select record_id from user_cut_record_0413 GROUP BY record_id…
delete from table1 where ID not in(select max(ID) ID from table1 group by row1) and row1 ) # 出现错误 # You can't specify target table 't_zqqk_stockinfo_copy2' for update in FROM clause 不能从子句中指定目标表“TY-ZQQKYStknfOfCopy2”用于更新 delete from table1 where ID no…
错误的意思说,不能先select出同一表中的某些值,再update这个表(在同一语句中). 例如下面这个sql: delete from tbl where id in (        select max(id) from tbl a where EXISTS        (            select 1 from tbl b where a.tac=b.tac group by tac HAVING count(1)>1        )        group by tac…
这个错误是说从t表select出来的无法又更新t表. 可以在select的时候先取个别名,弄个临时表即可.…
mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中). 例:DELETE from sys_org_relation where pOrgid in ( select porgId from sys_org_relation   r  where  r.corgid='客户id' and relationType=1112 )  and…