>delete FROM password WHERE password.uname IN
>(select uname FROM user WHERE status = "old");

Looks like this isnt possible in MySQL. :(
Excerpt from the MySQL manual:

8<-------8<-------8<-------8<-------8<-------8<-------

20.19  Deleting rows from related tables

As MySQL doesn't support sub-selects or use of more
than one table in the DELETE statement, you should use
the following approach to delete rows from 2 related
tables:
1. SELECT the rows based on some WHERE condition in the
   main table.
2. DELETE the rows in the main table based on the same
   condition.
3. DELETE FROM related_table WHERE related_column IN
   (selected_rows)

8<-------8<-------8<-------8<-------8<-------8<-------

As I understood, you dont want to do (2.) Therefore,
you would need 2 statements and buffer the result of the
first one:

select uname from user where status='old';
$var = (uname_1, uname_2, ..., uname_n)
delete from passwd where uname in $var;

Not a very nice way to go. Maybe someone knows better?

cheers,
christian


-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug

Reply via email to