Home » SQL & PL/SQL » SQL & PL/SQL » not exists
not exists [message #39701] Fri, 02 August 2002 10:32 Go to next message
Sean
Messages: 22
Registered: July 2000
Junior Member
I am trying to perform a delete on one table of any rows where columnA does not exist on another table in columnB. I can't seem to get it working...any advice?
Re: not exists [message #39702 is a reply to message #39701] Fri, 02 August 2002 10:35 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
delete
  from t1
 where not exists (select null
                     from t2
                    where t2.columnb = t1.columna);
Re: not exists [message #39705 is a reply to message #39701] Fri, 02 August 2002 11:18 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
There has to be some value in the column list - it could be NULL, a constant (1), any column(s) in t2. The actual value is irrelevant since the NOT EXISTS is just checking for a result set with no rows. It doesn't care what values are in the rows.
Previous Topic: Re: Select from a remote database...
Next Topic: pl/sql program constructs
Goto Forum:
  


Current Time: Thu Mar 28 12:20:37 CDT 2024