List:General Discussion« Previous MessageNext Message »
From:Jeff Mckeon Date:July 8 2008 5:12pm
Subject:RE: delete query question
View as plain text  
Thanks, that did it!

> -----Original Message-----
> From: Peter Brawley [mailto:peter.brawley@stripped]
> Sent: Tuesday, July 08, 2008 11:57 AM
> To: Jeff Mckeon
> Cc: mysql@stripped
> Subject: Re: delete query question
> 
> Jeff,
> 
> >Table2.ticket = table1.ID
> >Table2 is a many to 1 relationship to table1
> >I need to delete all records from table1 where created <
> >unix_timestamp(date_sub(now(), interval 3 month))
> >And all rows from table2 where Table2.ticket = Table1.ID
> >(of the deleted rows..)
> 
> Like this (untested)?
> 
> DELETE table1,table2
> FROM table1 t1
> JOIN table2 t2 ON t1.id=t2.ticket
> WHERE t2.created < UNIX_TIMESTAMP( DATE_SUB( NOW(), INTERVAL 3 MONTH ))
> ;
> 
> PB
> 
> -----
> 
> Jeff Mckeon wrote:
> > I think this is possible but I'm having a total brain fart as to how
> to
> > construct the query..
> >
> > Table2.ticket = table1.ID
> >
> > Table2 is a many to 1 relationship to table1
> >
> > I need to delete all records from table1 where created <
> > unix_timestamp(date_sub(now(), interval 3 month))
> > And all rows from table2 where Table2.ticket = Table1.ID (of the
> deleted
> > rows..)
> >
> > Can't this be done in one query? Or two?
> >
> > Thanks,
> >
> > Jeff
> >
> >
> >
> >
> >

Thread
delete query questionJeff Mckeon8 Jul
  • Re: delete query questionIan Simpson8 Jul
    • RE: delete query questionJeff Mckeon8 Jul
      • RE: delete query questionIan Simpson8 Jul
  • Re: delete query questionPeter Brawley8 Jul
    • RE: delete query questionJeff Mckeon8 Jul