Hi.

On Mon, Oct 01, 2001 at 04:48:36PM -0400, [EMAIL PROTECTED] wrote:
> I'm trying to remove rows from one table where a column matches another
> column in a seperate table..
> 
> I have mysql 3.22.32:
> 
> DELETE TemporaryUsers_ToMessWith.* FROM TemporaryUsers_ToMessWith,
> Advantage_Backup WHERE Advantage_Backup.TempAccountNumber =
> TemporaryUsers_ToMessWith.TempAccountNumber AND
> TemporaryUsers_ToMessWith.TempAccountNumber <> 0;
> 
> I tried that and then realized I need mysql 4.0.0 or higher to do that kind
> of query.
> 
> I don't want to delete from multiple tables, just one, but I need to match
> it with the 2nd table there.. so how would I go about writing that query?
[...]

This would also be considered a multi-table-delete, which will work
only in the upcoming 4.0. In 3.23.x the delete statement may only
refer to one table.

Best is probably to do this with a programming language: first select
the ids of all rows in questions

SELECT  tu.Id 
FROM    TemporaryUsers_ToMessWith AS tu,
        Advantage_Backup AS ab 
WHERE   ab.TempAccountNumber = tu.TempAccountNumber AND
        tu.TempAccountNumber <> 0;

then issue one large

DELETE FROM TemporaryUsers_ToMessWith WHERE id in (<your id list>)

Of course, that presumes that you have an reasonable id in your table,
which you have, don't you? ;-)

Bye,

        Benjamin.

-- 
[EMAIL PROTECTED]

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to