關于mysql delete的問題,需要的朋友可以參考下。
由于mysql數據庫的相關內部問題
導致delete from table where col not in (select col from table group by xx)
會提示報錯
我們要做的是
代碼如下:
create table tmp selete col from table group by xx;
delete from table where col not in (select col from tmp);
drop table tmp;
今天,在開發自己的項目中需要把項目原來的數據導入到新的系統中,在這個過程中會產生部分臟數據。
我們需要把這部分臟數據刪除到,在刪除的過程中我寫的delete sql語句不能執行不知道為什么,可以同樣的語句執行
select 是沒有問題的
如:
delete from student a where a.id in (1,2);()
select a.* from student a where a.id in (1,2);()
這是什么原因了呢?
結果處理:
delete 在寫操作一張表的時候 不用別名操作成功!
如:
delete from student where id in (1,2);()
我使用mysql版本:5.1.30-community-log
這是在開發中遇到的一個小問題,積累起來。
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END