References NULL field

From: Paul M Foster <paulf(at)quillandmouse(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: References NULL field
Date: 2006-04-03 03:43:34
Message-ID: 443099E6.3070101@quillandmouse.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

This is PostgreSQL 7.4 (long story). I have a table, registrars, which
has, among other things,

note_id integer references notes

The notes table has, among other things,

note_id integer default nextval('notes_seq')

Right now, there's nothing in the notes table, and all the records in
the registrars table have null for their note_id field.

I want to do a query (in PHP, FWIW) that returns all the fields in
registrars, and the contents of any relevant notes records, or null for
those fields if there is no corresponding record in the notes table. But
when I do

SELECT * FROM registrars, notes WHERE regname = 'blah'

no matter that I put after the 'blah' (or nothing), I get no results. As
soon as I add notes into the tables being queried, I get nothing.

There's some special way I need to shape this query, but I don't know
what it is. Any help would be appreciated.

--
Paul M. Foster

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Fuhr 2006-04-03 03:57:22 Re: References NULL field
Previous Message Ross Johnson 2006-04-02 12:15:26 Re: cross tables, SELECT expressions, and GROUP BY problem