前沿拓展:
delete语句
DML;DDL
如果需要在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)
参考资料来源:百度百科-DELETE语句
delete语句
DELETE 语句
DELETE 语句用于删除表中的行。
语法
DELETE FROM 表名称 WHERE 列名称 = 值
删除某行
"Fred Wilson" 会被删除:
DELETE FROM Person WHERE LastName = 'Wilson'
删除所有行
可以在不删除表的情况下删除所有的行。这意味着表的结构、属性和索引都是完整的:
DELETE FROM table_name
或者:
DELETE * FROM table_name
本回答被网友采纳
delete语句
delete (字段名)from 数据表 where 字句
例如:delete from 学生表 where 学号='123456'
本回答被提问者采纳
delete语句
delete XXXX表 where XXX=XXX
原创文章,作者:九贤生活小编,如若转载,请注明出处:http://www.wangguangwei.com/16391.html