Re: Updating with a subselect

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: Updating with a subselect
Дата
Msg-id 20080423065541.S588@megazone.bigpanda.com
обсуждение исходный текст
Ответ на Updating with a subselect  ("Leandro Casadei" <mateamargo@gmail.com>)
Ответы Re: Updating with a subselect
Список pgsql-general
On Tue, 22 Apr 2008, Leandro Casadei wrote:

> 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

I think you'll actually want something simpler. The following might do
what you want.

update shops
set    itemsqty =
    (
    select     count(*)
    from     items i1
    where   i1.shopid = shops.shopid
    )

В списке pgsql-general по дате отправления:

Предыдущее
От: "Kerri Reno"
Дата:
Сообщение: Re: FW: Re: create temp in function
Следующее
От: "Albe Laurenz"
Дата:
Сообщение: Re: Deny creation of tables for a user