High一下! --from coolshell

mysql 批量删除之大坑

首选先看看这条语句

DELETE  FROM
  tb_task t 
WHERE t.`groupname` = 'xxx' 
  AND t.`create_time` > '2013-08-20 14:24:00' 
  AND t.`filter` IS NULL 

这句代码在sql里会报错, 由于 tb_task 取了别名 所以,需要在 delete 和from中间 加上别名 t.

详见最后个答案 [http://stackoverflow.com/questions/4471277/mysql-delete-from-with-subquery-as-condition]  

mysql manual [http://dev.mysql.com/doc/refman/5.5/en/delete.html]

 

posted @ 2013-08-20 17:13  庄周梦蝶,黄粱一枕  阅读(300)  评论(1编辑  收藏  举报