Re: query join issue

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: Christine Penner <chris(at)fp2(dot)ca>
Cc: Postgres-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: query join issue
Date: 2010-09-16 17:22:15
Message-ID: 4C925247.20505@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 16/09/2010 16:05, Christine Penner wrote:
> I have a query that joins 3 tables, TRAIN_MOD,TRAIN_COMP and
> TRAINING_COURSE,
>
> There could be many training_course records for each of the other
> tables. I want to get all records from the Train_mod and Train_comp
> table even if there are no training course records available. This is
> the query I'm trying and I get nothing. The data I'm trying this on has
> no training_course records but does have records in the other tables.
> What am I doing wrong.
>
>
> SELECT *
> FROM TRAIN_MOD LEFT OUTER JOIN TRAINING_COURSE ON
> TRAIN_MOD.TRM_SEQ_NO=TRAINING_COURSE.TC_TRM_SEQ
> LEFT OUTER JOIN TRAIN_COMP ON TRAIN_MOD.TRM_TRC_SEQ=TRAIN_COMP.TRC_SEQ_NO
> where TC_PUB_ED IS TRUE OR TC_SEQ_NO IS NULL

Can you show us the table schemas?

Also, I think it's a good idea to qualify the columns in the WHERE
clause, to prevent any possible ambiguity. Without seeing the table
definitions I'm only guessing, but is it possible that these are doing
something other than what you expect?

Ray.

PS - I personally find all-caps SQL very hard to read. :-)

--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Christine Penner 2010-09-16 17:33:53 Re: query join issue
Previous Message Dean Rasheed 2010-09-16 17:04:29 Re: value