| From: | Masaru Sugawara <rk73(at)sea(dot)plala(dot)or(dot)jp> | 
|---|---|
| To: | Andre Schubert <andre(at)km3(dot)de> | 
| Cc: | pgsql-sql(at)postgresql(dot)org | 
| Subject: | Re: Need Help for select | 
| Date: | 2002-08-14 12:57:02 | 
| Message-ID: | 20020814201310.C84C.RK73@sea.plala.or.jp | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-sql | 
On Wed, 14 Aug 2002 09:10:53 +0200
Andre Schubert <andre(at)km3(dot)de> wrote:
> The ride side as follows.
> Table d contains information about subitems.
> Table c holds information about subitems and items of type bar.
> Each subitem can have 0..n items bar selected.
> 
> What i want is that a subitem is only activated for a foo item if
> the foo-item has exactly selected the same bar items selected as
> as the relation between table c and d.
> 
> Example 1:
> The foo-item A_Name1 has selected the bar-items 1 and 2.
> The subitem D_Name1 is only activated for a foo-item if that foo-item
> has selected the bar-items 1 and 2, this happens for A_Name1.
> 
If this mention implies that the tuple of (1, 1) in the c is supposed
to take precedence over that of (2, 1),
SELECT a.name, d.name
FROM (SELECT DISTINCT min(b.a_id) AS a_id, c.d_id
        FROM b, c
       WHERE b.c_id = c.b_id
      GROUP BY b.c_id, c.d_id
      ) AS t, 
      a, 
      d
WHERE a.id = t.a_id
  AND d.id = t.d_id
Regards,
Masaru Sugawara
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Oliver Elphick | 2002-08-14 13:02:59 | Re: parser: parse error at or near "$1" | 
| Previous Message | Sugandha Shah | 2002-08-14 12:29:26 | Re: Few Queries |