I have a table of users and also a table of cost centres they have access
to in a one to many relationship. I have done a purge of old users and
now wish to clean up the cost centre access table. I can do the following
query to find out which rows in the cost centre access table I wish to
delete:-
select a.user,b.user from cc a left outer join users b on a.user=b.user
where b.user is null;
+----------+
| user     |
+----------+
| tst-5328 |
| tst-3443 |
| tst-4361 |
| xxx-003  |
| tst-3502 |
| tst-3444 |
| tst-4859 |
| AAA-1    |
| AAA-2    |
| AAA-2    |
...
... for about 4000 more lines

All the cases where b.user is null I wish to delete from the cc table. Is
there a way of doing this:-
delete from cc select a.user from cc a left outer join users b 
on a.user=b.userwhere b.user is null;

There has to be a better way than having to write a perl script to do it
surely?

---<GRiP>---
Corporate Express Australia - Electronic Commerce Team
Order office products from http://www.ce.com.au
Ph 02-9335-0435  Fax 02-9335-0753  Helpdesk 02-9335-0501
Opinions expressed in this message are my own and not representative of
my employer Corporate Express Australia Limited.

--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to [EMAIL PROTECTED] with
unsubscribe in the text

Reply via email to