What kind of JOIN, if any?

Поиск
Список
Период
Сортировка
От Paul M Foster
Тема What kind of JOIN, if any?
Дата
Msg-id 20090917142911.GI28540@quillandmouse.com
обсуждение исходный текст
Ответы Re: What kind of JOIN, if any?  (Serge Fonville <serge.fonville@gmail.com>)
Re: What kind of JOIN, if any?  (Sam Mason <sam@samason.me.uk>)
Re: What kind of JOIN, if any?  (Mark Styles <postgres@lambic.co.uk>)
Список pgsql-general
Folks:

I can't find a way to do this purely with SQL. Any help would be
appreciated.

Table 1: urls

id | url
--------------
1  | alfa
2  | bravo
3  | charlie
4  | delta

Table 2: access

userid | url_id
---------------
paulf  | 1
paulf  | 2
nancyf | 2
nancyf | 3

The access table is related to the url table via url_id = id.

Here's what I want as a result of a query: I want all the records of the
url table, one row for each record, plus the userid field that goes with
it, for a specified user (paulf), with NULLs as needed, like this:

userid | url
-------------
paulf  | alfa
paulf  | bravo
       | charlie
       | delta

I can do *part* of this with various JOINs, but the moment I specify
userid = 'paulf', I don't get the rows with NULLs.

Again, any help would be appreciated.

Paul

--
Paul M. Foster

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

Предыдущее
От: el dorado
Дата:
Сообщение: Re[2]: Problems with pg_dump for PG8.4 for WinXP (MinGW build)
Следующее
От: Serge Fonville
Дата:
Сообщение: Re: What kind of JOIN, if any?