Simple OUTER JOIN doubt - Mailing list pgsql-general

From Sandro Dentella
Subject Simple OUTER JOIN doubt
Date
Msg-id 20061027184830.GA21813@casa.e-den.it
Whole thread Raw
Responses Re: Simple OUTER JOIN doubt
Re: Simple OUTER JOIN doubt
List pgsql-general
I've a very simple task. I thought I knew how to solve it but there's
something I'm surely missing.

I got film and scores for the film. In table "film" and "punteggio"
(score). I want a join returning all the films and the votes
expressed by the user(s).  If the user did not vote I want a NULL.

I only get films for which a vote was expressed. My query:

       SELECT f.id, f.titolo, p.voto
       FROM film_film f
       LEFT OUTER JOIN vota_punteggio  p
       ON (f.id = p.film_id)
       WHERE
       (p.user_id = 2 OR p.user_id IS NULL)


Can you help me understanding what is wrong?
TIA
sandro
*:-)



cinemino=# \d film_film
                                    Tabella "public.film_film"
     Colonna     |          Tipo          |                      Modificatori
-----------------+------------------------+--------------------------------------------------------
 id              | integer                | not null default nextval('film_film_id_seq'::regclass)
 titolo          | character varying(100) | not null
 regista         | character varying(40)  |
 url_iann        | character varying(200) |
 url_altri       | character varying(200) |
 anno            | integer                |
 image           | character varying(100) |
 durata          | integer                |
 genere_id       | integer                |
 data_proiezione | date                   |
 proposto_da     | integer                |

cinemino=# \d vota_punteggio
                         Tabella "public.vota_punteggio"
 Colonna |  Tipo   |                        Modificatori
---------+---------+-------------------------------------------------------------
 id      | integer | not null default nextval('vota_punteggio_id_seq'::regclass)
 voto    | integer | not null
 user_id | integer | not null
 film_id | integer | not null



--
Sandro Dentella  *:-)
e-mail: sandro@e-den.it
http://www.tksql.org                    TkSQL Home page - My GPL work

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: CREATE TABLE initial value for PRIMARY KEY
Next
From: Richard Broersma Jr
Date:
Subject: Re: CREATE TABLE initial value for PRIMARY KEY