JOIN question

Поиск
Список
Период
Сортировка
От Frank Morton
Тема JOIN question
Дата
Msg-id 000d01c18b1e$9ba84320$8455e5ce@edison
обсуждение исходный текст
Ответ на Re: NULL values or not?  ("Josh Berkus" <josh@agliodbs.com>)
Ответы Re: JOIN question  (Peter Eisentraut <peter_e@gmx.net>)
Re: JOIN question  (Ian Barwick <barwick@gmx.net>)
Список pgsql-sql
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.




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

Предыдущее
От: Archibald Zimonyi
Дата:
Сообщение: Re: NULL values or not?
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: JOIN question