APM: DBI multi table delete

Evan Harris eharris at puremagic.com
Mon Feb 23 11:12:43 CST 2004


Your problem is probably that you need to fully specify the table fields.
Try:

DELETE FROM t1,t2,t3,t4,t5 WHERE t1.username = 'joe' OR t2.usernam = 'joe'
OR t3.username = 'joe' OR t4.username = 'joe' OR t5.username = 'joe'

I've never done multitable delets, so I don't know if that even works, but
if it does, the above should too, and should do what you want.

A sure way to do it is to do a seperate delete statement for each table.

Evan


On 23 Feb 2004, Jeremy Brooks wrote:

>
> I need to quickly come up with a sql statement to run from a perl/DBI
> script that deletes all records from several tables that have a
> particular username, 'joe', in the username column.  I know this is
> probably simple, but what I've done so far hasn't worked as expected.  I
> think that these are the correct DELETE and FROM clauses:
>
> DELETE t1,t2,t3,t4,t5 FROM t1,t2,t3,t4,t5
>
> But, I'm not sure how to write the condition that determines what
> records to delete.  let's say I want to delete any record from all of
> the tables that have a username value of 'joe'.
>
> Can some please show me exactly what the sql statement ought to be?
>
> thank in advance!
> -Jeremy
>
>
>
> _______________________________________________
> Austin mailing list
> Austin at mail.pm.org
> http://mail.pm.org/mailman/listinfo/austin
>




More information about the Austin mailing list