From: | Edmund Bacon <ebacon-xlii(at)onesystem(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: adding missing FROM-clause |
Date: | 2004-10-29 18:13:31 |
Message-ID: | m3d5z1gzp0.fsf@elb_lx.onesystem.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
csgcsg39(at)hotmail(dot)com ("C G") writes:
> Dear All,
>
> I have a simple join query
>
> SELECT c1 FROM t1
> INNER JOIN
> t2 ON t2.c2 = t1.c2 WHERE t3.c3= t2.c3;
>
> Which gives the expected result but I get the message
> NOTICE: adding missing FROM-clause entry for table "t3"
>
> How do I get rid of this NOTICE, i.e. how should I construct my select
> query.
>
SELECT c1 FROM t1, t2, t3
WHERE t2.c2 = t1.c2 AND t3.c3 = t2.c3;
or
SELECT c1 FROM t1
INNER JOIN t2 ON t2.c2 = t1.c2
INNER JOIN t3 ON T3.c3 = t2.c3;
The above can also be written as
SELECT c1 FROM t1
JOIN t2 USING(c2)
JOIN t3 USING(c3);
or even
SELECT c1 FROM t1
NATURAL JOIN t2
NATURAL JOIN t3;
This last might be problematic if t3 has a column named c1.
Question:
Is there any advantage to specifying USING() rather than ON? I know
that if I do SELECT * from T1 JOIN t2 USING(col) then I only get 1
instance of col in the returned rows, but I'm wondering if there is
any advantage to the planner by specifying either USING() or ON?
--
Remove -42 for email
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2004-10-29 18:14:14 | Re: tasks |
Previous Message | Tom Lane | 2004-10-29 17:53:28 | Re: tasks |