Re: Updating with a subselect
От | Leandro Casadei |
---|---|
Тема | Re: Updating with a subselect |
Дата | |
Msg-id | 5983afbb0804230738y6dcf6be7he7aa5e9935b51909@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Updating with a subselect (Stephan Szabo <sszabo@megazone.bigpanda.com>) |
Список | pgsql-general |
On Wed, Apr 23, 2008 at 10:59 AM, Stephan Szabo <sszabo@megazone.bigpanda.com> wrote:
On Tue, 22 Apr 2008, Leandro Casadei wrote:I think you'll actually want something simpler. The following might do
> Hi, I need to update a field from a table based in a count.
>
> This is the query:
>
>
> update shops
> set itemsqty =
> (
> select count(*)
> from items i1
> join shops s1 on i1.shopid = s1.shopid
> where s1.shopid = s0.shopid
> )
> from shops s0
what you want.where i1.shopid = shops.shopid
update shops
set itemsqty =
(
select count(*)
from items i1
)
Yes, thanks. I've received a similar answer in the PostgreSQL Forums.
I don't know why the join did't work.
I had to do this with another table, and the subselect needed a few joins, but I have replaced them with the table names separated by commas and it worked too.
Might this be some kind of bug?
В списке pgsql-general по дате отправления: