前沿拓展:
delete語句
DML;DDL
如果需要在delete的時(shí)候,按照條件刪除記錄,那么可能會用到子查詢。
但是如下情況:
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 子句中的結(jié)果集起別名。
delete from student where id = (select n.max_id from (select max(id) as max_id from student) as n);
這個(gè)方法對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'
刪除所有行
可以在不刪除表的情況下刪除所有的行。這意味著表的結(jié)構(gòu)、屬性和索引都是完整的:
DELETE FROM table_name
或者:
DELETE * FROM table_name
本回答被網(wǎng)友采納
delete語句
delete (字段名)from 數(shù)據(jù)表 where 字句
例如:delete from 學(xué)生表 where 學(xué)號='123456'
本回答被提問者采納
delete語句
delete XXXX表 where XXX=XXX
原創(chuàng)文章,作者:九賢生活小編,如若轉(zhuǎn)載,請注明出處:http://xiesong.cn/16391.html