MySQL--Delete语句别名+LIMIT
生活随笔
收集整理的這篇文章主要介紹了
MySQL--Delete语句别名+LIMIT
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在MySQL中,可以使用LIMIT來限制刪除的數量,但部分寫法并不支持LIMIT.
LIMIT方式
對于查詢: SELECT * FROM T1 LIMIT 1; 可以轉換成: DELETE FROM T1 LIMIT 1;別名方式:
## 使用別名 DELETE T FROM T1 AS T;但MySQL不支持別名+LIMIT方式,如:
查詢: SELECT * FROM T1 AS T LIMIT 1; 不能轉換為: DELETE T FROM T1 AS T LIMIT 1;?
對于多表關聯操作,同樣不允許別名+LIMIT操作,但可以將LIMIT放入子查詢中:
對于查詢: SELECT * FROM TB_1 AS T1 LEFT JOIN TB_2 AS T2 ON T1.ID = T2.ID WHERE T2.ID IS NULL LIMIT 10;不能修改為: DELETE T1 FROM TB_1 AS T1 LEFT JOIN TB_2 AS T2 ON T1.ID = T2.ID WHERE T2.ID IS NULL LIMIT 10;
需要轉換為: DELETE T1 FROM TB_1 AS T1 (SELECT T1.ID FROM TB_1 AS T1 LEFT JOIN TB_2 AS T2 ON T1.ID = T2.ID WHERE T2.ID IS NULL LIMIT 10) AS T3 INNER JOIN TB_2 AS T2 ON T1.ID=T2.ID
?
轉載于:https://www.cnblogs.com/gaogao67/p/10391972.html
總結
以上是生活随笔為你收集整理的MySQL--Delete语句别名+LIMIT的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Typescript中class的ext
- 下一篇: jmeter压测之 监控--nmon