开发者

Mysql Trigger to select and delete

Is this possible, can a trigger in mysql can do a select first and then based on its result do a delete?, both on the same table.

Am struggling t开发者_开发技巧o get it right.

There are duplicate entries in a table, i need to have a trigger which selects and then deletes.

Any ideas or thoughts will be really helpful.


You can delete records based on your select using subqueries, you can check it here: link text

A simple example is this:

DELETE FROM `tblname` WHERE `id` IN (SELECT `id` FROM `tblname` WHERE `field` = 'must_be_deleted')


If it is only one-time deletion then no need to use triggers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜