delete语句
如果需要在delete的时候,按照条件删除记录,那么可能会用到子查询。
但是如下情况:
delete from student where id = (select max(id) from student);
[Err] 1093 - You can't specify target table 'student' for update in FROM clause
解决办法是:给 from 子句中的结果集起别名。
delete from student where id = (select n.max_id from (select max(id) as max_id from student) as n);
这个方法对in还是适用的
delete from student where id in (select id from student where id > 30);
[Err] 1093 - You can't specify target table 'student' for update in FROM clause
解决方法同上:
delete from student where id in (select n.id from (select id from student where id > 30) as n);
转:https://www.cnblogs.com/dwarcheng/p/5887207.html
相关阅读
python版本:3.7.1 安装依赖包requests re urllib bs4...... 安装方法:打开python安装目录,找到scripts的目录,按住shift出现打开命
#include <stdio.h>#include <stdlib.h>#include <string.h> struct stu { char name[30]; long int id ; int c
【Selenium_Web_Xpath定位】12306火车票官方订票网站,
#!/usr/bin/env/python3 # -*- coding:utf-8 -*- ''' Author:leo Date&Time:2019-07-27 and 12:22 FileName:12306_成都到重庆 De
五种基本句型之 主语+谓语+宾语 +宾语补足语 这个句型在有的语法书上又叫做主语+谓语+复合宾语,这里的复合宾语=宾语+宾语补足语,这里又
近日来,对于腾讯音乐和网易云音乐可谓大事不断,尤其是日前火得一塌糊涂的周杰伦新歌《说好不哭》,更是在上线约短短两小时,在QQ音乐、