tags:

views:

33

answers:

2

Hi,

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 to 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.

+1  A: 

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')
jmslouie
A: 

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

Vinayak Mahadevan