On Fri, Jan 21, 2011 at 9:59 AM, Wade Preston Shearer <[email protected]> wrote: > I have an MySQL table with a foreign key and a created date. I'd like to > delete all rows that match the foreign key except he most recent one. Is that > possible in a single query? >
Something like this should do it: delete table1 from table1 inner join table2 on table1.table2_id = table2.id where table2.created_date > '2011-01-01' Alvaro _______________________________________________ UPHPU mailing list [email protected] http://uphpu.org/mailman/listinfo/uphpu IRC: #uphpu on irc.freenode.net
