List:General Discussion« Previous MessageNext Message »
From:Sinisa Milivojevic Date:January 25 2002 10:26am
Subject:Re: Inner Join Delete
View as plain text  
Jeremy Zawodny writes:
> On Wed, Jan 23, 2002 at 11:25:31PM -0500, Jason Yates wrote:
> > Heres an example scenario, say I have two tables
> > 
> >        table1
> > ----->	id
> > |	name
> > |
> > |       table2
> > |_____> id 
> > 	address
> > 	zip
> > 
> > I inner join table1 and table2 on id.  I want to delete all the
> > records in table1 which have a zip of '90210'.
> 
> Good choice.  90210 is first to go on my list, too. :-)
> 
> > I could create a script, run a select and loop through each id and
> > delete the records in table1.
> 
> If you're running MySQL 4.x, multi-table deletes:
> 
>   http://www.mysql.com/doc/D/E/DELETE.html
> 
> may be what you need, if I understand you right.
> 
> Otherwise, you've gotta write that loop.
> 
> Jeremy
> -- 
> Jeremy D. Zawodny, <jzawodn@stripped>
> Technical Yahoo - Yahoo Finance
> Desk: (408) 349-7878   Fax: (408) 349-5454   Cell: (408) 685-5936
> 
> MySQL 3.23.41-max: up 22 days, processed 514,844,619 queries (266/sec. avg)
> 


Or use multi-table delete feature from  4.0.1 ... 

-- 
Regards,
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Mr. Sinisa Milivojevic <sinisa@stripped>
 / /|_/ / // /\ \/ /_/ / /__   MySQL AB, Fulltime Developer
/_/  /_/\_, /___/\___\_\___/   Larnaca, Cyprus
       <___/   www.mysql.com

Thread
Inner Join DeleteJason Yates24 Jan
  • Re: Inner Join DeleteJeremy Zawodny25 Jan
    • Re: Inner Join DeleteSinisa Milivojevic25 Jan