Getting one row for each subquery row...?

Lists: pgsql-general
From: "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com>
To: "pg-general (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: adding comments to a table
Date: 2003-06-05 15:18:24
Message-ID: 73309C2FDD95D11192E60008C7B1D5BB05FED3D4@snt452.corp.bcbsm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Howdy:

Running PostgreSQL 7.2.1 on RedHat Linux 7.2.

I have a table where I'm the owner, but I want to give
all permission to another person. So, I do a
'grant all on <table> to <joe_user>' and it seems that
they have all the rights that I do.

But they are not able to add a comment to the table.

Is this a table creator-only ability? How can I give
the new person the ability to add a comment to
the table?

Thanks!

-X


From: Együd Csaba <csegyud(at)freemail(dot)hu>
To: pgsql-general-owner(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Getting one row for each subquery row...?
Date: 2003-06-20 04:43:55
Message-ID: 003d01c336e6$9c936830$230a0a0a@compaq
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

adding comments to a tableHi All,
here are my three tables. I wold like to list them in the following way: I need all the columns from t_stockchanges, and one field for the pgoductgroup the t_stockchanges.productid belongs to.

But one product can belong to many group, so i would need one row for each group for each product.

My bad query is:
------------------------
DB=# select t_stockchanges.productid, (select name from t_productgroups where id=(select productgroupid from t_prod_in_pgr where productid=t_stockchanges.productid)) as pgroup from t_stockchanges;
ERROR: More than one tuple returned by a subselect used as an expression.
DB=#
---------------
Yes, this is absolutelly true, but I would like postgres to give me all the tuples found. How can I ask him to do so?

Thank you,
-- Csaba

--------------------------------------------------------------------------------------------------------------------------------
Table "public.t_stockchanges"
Column | Type | Modifiers
---------------+------------------+-----------------------------------------------------
id | integer | not null
stockid | integer | not null
productid | integer | not null
changeid | integer | not null
quantity | double precision | not null
date | character(19) | not null
purchaseprice | double precision | not null
correction | double precision | not null
userid | integer | not null
time | character(19) | default to_char(now(), 'YYYY.mm.dd hh:mi:ss'::text)
prooftype | character(10) | not null default ''
proofid | integer | default 0
Indexes: t_stockchanges_pkey primary key btree (id),
t_stockchanges_date btree (date),
t_stockchanges_productid btree (productid)
--------------------------------------------------------------------------------------------------------------------------------

Table "public.t_productgroups"
Column | Type | Modifiers
-------------+-----------------------+-----------
id | integer | not null
name | character varying(30) | not null
description | character varying |
root | boolean |
Indexes: t_productgroups_pkey primary key btree (id)
--------------------------------------------------------------------------------------------------------------------------------

Table "public.t_prod_in_pgr"
Column | Type | Modifiers
----------------+---------+-----------
productgroupid | integer | not null
productid | integer | not null
--------------------------------------------------------------------------------------------------------------------------------

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.489 / Virus Database: 288 - Release Date: 2003. 06. 10.


From: darren(at)crystalballinc(dot)com
To: Együd Csaba <csegyud(at)freemail(dot)hu>
Cc: pgsql-general-owner(at)postgresql(dot)org, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Getting one row for each subquery row...?
Date: 2003-06-22 20:34:06
Message-ID: Pine.LNX.4.44.0306221633330.17218-100000@thread.crystalballinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Use the IN instead of = and this will allow Postgres to return more than
one row in the sub-select

Darren

On Fri, 20 Jun 2003, Együd Csaba wrote:

> adding comments to a tableHi All,
> here are my three tables. I wold like to list them in the following way: I need all the columns from t_stockchanges, and one field for the pgoductgroup the t_stockchanges.productid belongs to.
>
> But one product can belong to many group, so i would need one row for each group for each product.
>
> My bad query is:
> ------------------------
> DB=# select t_stockchanges.productid, (select name from t_productgroups where id=(select productgroupid from t_prod_in_pgr where productid=t_stockchanges.productid)) as pgroup from t_stockchanges;
> ERROR: More than one tuple returned by a subselect used as an expression.
> DB=#
> ---------------
> Yes, this is absolutelly true, but I would like postgres to give me all the tuples found. How can I ask him to do so?
>
> Thank you,
> -- Csaba
>
> --------------------------------------------------------------------------------------------------------------------------------
> Table "public.t_stockchanges"
> Column | Type | Modifiers
> ---------------+------------------+-----------------------------------------------------
> id | integer | not null
> stockid | integer | not null
> productid | integer | not null
> changeid | integer | not null
> quantity | double precision | not null
> date | character(19) | not null
> purchaseprice | double precision | not null
> correction | double precision | not null
> userid | integer | not null
> time | character(19) | default to_char(now(), 'YYYY.mm.dd hh:mi:ss'::text)
> prooftype | character(10) | not null default ''
> proofid | integer | default 0
> Indexes: t_stockchanges_pkey primary key btree (id),
> t_stockchanges_date btree (date),
> t_stockchanges_productid btree (productid)
> --------------------------------------------------------------------------------------------------------------------------------
>
> Table "public.t_productgroups"
> Column | Type | Modifiers
> -------------+-----------------------+-----------
> id | integer | not null
> name | character varying(30) | not null
> description | character varying |
> root | boolean |
> Indexes: t_productgroups_pkey primary key btree (id)
> --------------------------------------------------------------------------------------------------------------------------------
>
> Table "public.t_prod_in_pgr"
> Column | Type | Modifiers
> ----------------+---------+-----------
> productgroupid | integer | not null
> productid | integer | not null
> --------------------------------------------------------------------------------------------------------------------------------
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.489 / Virus Database: 288 - Release Date: 2003. 06. 10.
>

--
Darren Ferguson