Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > Updating with a...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 3428 of 3661
Post > Topic >>

Updating with a subselect

by mateamargo <mateamargo@[EMAIL PROTECTED] > Apr 22, 2008 at 12:43 PM

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


The problem I'm having is that all the shops are updated with the
items quantity of the first shop.
I've tried using the count without a subselect, but PostgreSQL
complains about it.

How can I do this?
 




 3 Posts in Topic:
Updating with a subselect
mateamargo <mateamargo  2008-04-22 12:43:16 
Re: Updating with a subselect
mateamargo <mateamargo  2008-04-22 12:52:22 
Re: Updating with a subselect
Dennis Muhlestein <djm  2008-04-24 16:11:39 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Sep 6 15:41:41 CDT 2008.