mysql数据库在执行同时查询本表数据并删除本表数据时候,报错!

报错原因:

  1. DELETE from sys_user_function
  2. where User_Id = 19 and Function_Id in (
  3. select s.Function_Id from sys_user_function s where s.User_Id=19
  4. )

修改如下:

  1. delete from sys_user_function where User_Id = 19 AND
  2. Function_Id in
  3. (
  4. select a.Function_Id from
  5. (
  6. select max(Function_Id) Function_Id from sys_user_function a where a.User_Id=20 and EXISTS
  7. (
  8. select 1 from sys_user_function b where a.User_Id=b.User_Id group by User_Id HAVING count(1)>=1
  9. )
  10. group by Function_Id
  11. ) a
  12. )

  

You can't specify target table 'sys_user_function' for update in FROM clause的更多相关文章

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

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

  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 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 ...

  4. 错误:You can't specify target table 'xxx' for update in FROM clause的解决

    问题: 今天在MySQL数据库删除重复数据的时候遇到了一个问题.如下脚本: DELETE FROM tempA WHERE tid IN ( SELECT MAX(tid) AS tid FROM t ...

  5. [Err] 1093 - You can't specify target table 's' for update in FROM clause

    [Err] 1093 - You can't specify target table 's' for update in FROM clause 执行SQL DELETE from book WHE ...

  6. 【MySQL】解决You can't specify target table 'user_cut_record_0413' for update in FROM clause

    问题 You can't specify target table 'user_cut_record_0413' for update in FROM clause 原因 待更新/删除的数据集与查询的 ...

  7. You can't specify target table 'ship_product_cat' for update in FROM clause

    有时候我们在编辑update时需要select作为条件,在mysql中有时会出现这样的错误:You can't specify target table for update in FROM clau ...

  8. MySQL中执行sql语句错误 Error Code: 1093. You can't specify target table 'car' for update in FROM clause

    MySQL中执行sql语句错误 Error Code: 1093. You can't specify target table 'car' for update in FROM clause 201 ...

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

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

随机推荐

  1. Leetcode之回溯法专题-40. 组合总和 II(Combination Sum II)

    Leetcode之回溯法专题-40. 组合总和 II(Combination Sum II) 给定一个数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使 ...

  2. C# 生产者与消费者模式

    情景:一个线程不断获取数据,另一个线程不断处理这些数据. 常规方法:数据列表加锁,两个线程获取锁,拿到操作权:类似代码如下:(不推荐) static void Main(string[] args) ...

  3. codeforces 879 D. Teams Formation(思维)

    题目链接:http://codeforces.com/contest/879/problem/D 题意:这题题意我反正是看了很久,可能是我的理解能力有点差,就是将一个数组倍增m倍然后将连续的相同的k个 ...

  4. CF1027C Minimum Value Rectangle 贪心 数学

    Minimum Value Rectangle time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  5. CodeForces Round 525

    A:Ehab and another construction problem #include<bits/stdc++.h> using namespace std; #define F ...

  6. codeforces 361 C. Levko and Array Recovery(暴力+思维)

    题目链接:http://codeforces.com/contest/361/problem/C 题意:对一个数列有这么两个操作 1.(1,l,r,p)..将区间[l,r]所有数都加上p 2.(2,l ...

  7. 深入vue源码,了解vue的双向数据绑定原理

    大家都知道vue是一种MVVM开发模式,数据驱动视图的前端框架,并且内部已经实现了双向数据绑定,那么双向数据绑定是怎么实现的呢? 先手动撸一个最最最简单的双向数据绑定 <div> < ...

  8. CentOS 7 下网络无法访问 Failed to start LSB: Bring up/.

    [root@localhost Desktop]# ping 192.168.2.1PING 192.168.2.1 (192.168.2.1) 56(84) bytes of data.64 byt ...

  9. Git使用(二)版本库创建及文件修改

    一.创建版本库 1.安装完成后,在开始菜单里找到“Git”->“Git Bash”,蹦出一个类似命令行窗口的东西,就说明Git安装成功! 安装完成后,还需要最后一步设置,在命令行输入: $ gi ...

  10. win下的mongodb安装和基础操作

    一.下载地址: https://www.mongodb.com/download-center/community 二.安装错误: 1.安装过程中报错(类似下图): 原因:没有管理员权限 解决:管理员 ...