Re: Subselects lack functionality - Mailing list pgsql-bugs

From Lamar Owen
Subject Re: Subselects lack functionality
Date
Msg-id 39D3C444.B7BFEF66@wgcr.org
Whole thread Raw
In response to Subselects lack functionality  (pgsql-bugs@postgresql.org)
List pgsql-bugs
pgsql-bugs@postgresql.org wrote:
> 2.
> It would be gr8 if single column subselects would allow themselves to be treated the same way as lists do as
right-sidearguments of IN operator. 
> This would allow e.g. much more powerful DELETE statement, like
> DELETE FROM table WHERE id IN (SELECT ...)

This, AFAIK, works.  I am using just that construct in UPDATE -- I would
assume DELETE would work...

Lessee...This works, as I just tested it on a client's database (inside
a transaction, with a rollback at the end, of course).  You say
something like

DELETE from users WHERE uid IN (SELECT uid FROM users WHERE username ~*
'testing')

to delete (of course, I know that that is a contrived example, but a
working one).

More complex is

DELETE from personal_data WHERE uid IN (SELECT uid FROM users WHERE
username ~* 'testing')

-- which works just fine on a client's database (again, inside a
transaction so I could easily roll back the delete :-)).

--
Lamar Owen
WGCR Internet Radio
1 Peter 4:11

pgsql-bugs by date:

Previous
From: pgsql-bugs@postgresql.org
Date:
Subject: Subselects lack functionality
Next
From: Tom Lane
Date:
Subject: Re: Subselects lack functionality