[ale] delete rows in mysql

James Sumners james.sumners at gmail.com
Wed May 5 10:26:18 EDT 2010


Give this a try.

delete from trigger where trigger_id IN ((select trigger_id from
trigger_group_map where trigger_group_id=3))


On 5/5/10, Chris Fowler <cfowler at outpostsentinel.com> wrote:
> I want to delete rows in a main table that are mapped in a 2nd table.
>
> I have a table called `trigger`.  It lists all the possible triggers.
> There is a group table called `trigger_group`.
> I map triggers to a trigger_group via the trigger_group_map table.
>
> I want to delete not only a trigger_group but also the triggers that are
> mapped to that group
>
> I've tried this
>
> delete from trigger where trigger_id=(select trigger_id from
> trigger_group_map where trigger_group_id=3)
>
> That gives me a result of 0 rows so there is obviously a better way to
> do this.  I can easily write a perl loop that will the following:
>
> select trigger_id from trigger_group_map where trigger_group_id=3
> for each
>   delete from trigger where trigger_id=X
>   delete from trigger_group_map where trigger_id=X
> done
>
>
> I've got a new list of triggers and I want to delete not only the
> mappings but the old triggers from trigger table before I import these.
>
> Chris
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>


-- 
James Sumners
http://james.roomfullofmirrors.com/

"All governments suffer a recurring problem: Power attracts
pathological personalities. It is not that power corrupts but that it
is magnetic to the corruptible. Such people have a tendency to become
drunk on violence, a condition to which they are quickly addicted."

Missionaria Protectiva, Text QIV (decto)
CH:D 59


More information about the Ale mailing list