pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Frank Morton <fmorton@base2inc.com>
To: pgsql-sql@postgresql.org
Subject: JOIN question
Date: Sat, 22 Dec 2001 14:26:50 -0500
Message-ID: <000d01c18b1e$9ba84320$8455e5ce@edison> (raw)
References: <web-533913@davinci.ethosmedia.com>

I'm looking for the most portable way to do the following,
given these two tables:

Table 1 is called "content" which contains an integer "id" column.
The value of this id is "1" for this example.

Table 2 is called "protection" and keeps track of who can read
and write the content object, so this table may contain multiple
protection settings for a single content object.

Simplifying, to consider my problem, the protection table contains
a column called "contentId", connecting it to the content table id.
This table has three rows in it for three groups that can read it
with contentId set to "1".

If I do the query:

select Content.* from Content,Protection
where (Content.id = Protection.contentId);

I get three rows back, corresponding to each group that has
access to the content. However, I would like to get back
just one row, corresponding to the content that fits the desired
protections.

How do I do this?

Thanks for answering this question for the relative sql newbie.





view thread (22+ messages)  latest in thread

Message-ID: <000d01c18b1e$9ba84320$8455e5ce@edison>
Permalink:  ../000d01c18b1e$9ba84320$8455e5ce@edison/
Also on:    postgresql.org/message-id/000d01c18b1e$9ba84320$8455e5ce@edison

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: fmorton@base2inc.com
  Subject: Re: JOIN question
  In-Reply-To: <000d01c18b1e$9ba84320$8455e5ce@edison>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox