Re: some external sql not working in psql - Mailing list pgsql-general

From Tom Lane
Subject Re: some external sql not working in psql
Date
Msg-id 19467.1239223326@sss.pgh.pa.us
Whole thread Raw
In response to some external sql not working in psql  (Kashmir <kashmir_us_1999@yahoo.com>)
List pgsql-general
Kashmir <kashmir_us_1999@yahoo.com> writes:
> being a sql-lamer, i used some query builder help to build my query (which served me quite well in the past for all
my'complicated' sqls), and was suggested for f_rrd_id=444 to use something as: 
> SELECT
> td_fetch1m_by_rrd_id.f_timestamp,
> td_fetch_by_rrd_id.f_ds,
> td_fetch_by_rrd_id.f_ds,
> td_fetch1m_by_rrd_id.f_ds,
> td_fetch1m_by_rrd_id.f_us
> FROM td_fetch_by_rrd_id
> RIGHT JOIN td_fetch1m_by_rrd_id ON td_fetch_by_rrd_id.f_timestamp=td_fetch1m_by_rrd_id.f_timestamp
> WHERE td_fetch1m_by_rrd_id.f_rrd_id=444
> ORDER BY td_fetch1m_by_rrd_id.f_timestamp;

Seems like that should be a LEFT JOIN, if you're expecting there to be
missing values in td_fetch_by_rrd_id rather than the other.  The WHERE
and ORDER BY clauses don't look right either unless LEFT was meant.

            regards, tom lane

pgsql-general by date:

Previous
From: "James B. Byrne"
Date:
Subject: Re: No return from trigger function
Next
From: Chris Browne
Date:
Subject: Re: Are there performance advantages in storing bulky field in separate table?