On Wed, 28 Mar 2001, Stephen Robert Norris wrote:

> > I have a table called password which has:
> > 
> > Field       Type 
> >  uname   varchar(64) Key
> >  passwd  varchar(16)
> > 
> > and another table user (partly shown) which has:
> > 
> > Field       Type
> >  uname    varchar(64) Key
> >  status     varchar(64)
> >  total       varchar(64)
> > 
> > and I am wishing to delete all users from passwd
> > where user.status = "old".
> > 
> > I have tried the following which according to MySQL
> > manual should work (Deleting Rows from Related Tables).
> > 
> > delete FROM password WHERE password.uname IN
> > (select uname FROM user WHERE status = "old");

> What happens? Does the subselect (if run by itself) produce the results
> you expect?

Hi Stephen, Antony & List.

>> What happens?
(Actual delete statement)? MySQL errors saying:

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

ERROR 1064: You have an error in your SQL syntax 
near 'select uname FROM user WHERE status = "old")' 
at line 1   

>> Does the subselect (if run by iteself) produce the
results you expect? 

Yes. Gives me a list of unames as expected.

If I do a select like:
select * FROM password, user WHERE password.uname = user.uname
AND user.status = "old"; 

I get a valid list of corresponding accounts.

>> Do I have MySQL priviliges to delete ? 
Yes I am root, and have all priviliges enabled.
(I have double checked).

In case it helps, I am running release MySQL 3.22.32

Thanks Grahame

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

Reply via email to