dbTalk Databases Forums  

adding missing FROM-clause

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss adding missing FROM-clause in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
C G
 
Posts: n/a

Default adding missing FROM-clause - 10-29-2004 , 10:42 AM






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.

Many thanks

Colin

__________________________________________________ _______________
Want to block unwanted pop-ups? Download the free MSN Toolbar now!
http://toolbar.msn.co.uk/


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


Reply With Quote
  #2  
Old   
Edmund Bacon
 
Posts: n/a

Default Re: adding missing FROM-clause - 10-29-2004 , 01:13 PM






csgcsg39 (AT) hotmail (DOT) com ("C G") writes:

Quote:
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


Reply With Quote
  #3  
Old   
Uwe C. Schroeder
 
Posts: n/a

Default Re: adding missing FROM-clause - 10-29-2004 , 07:37 PM



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 29 October 2004 08:42 am, C G wrote:
Quote:
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;
^^^^^
Your join doesn't alias anything as t3
I'd say you get rid of the notice once you replace t3 with t1

Quote:
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.

Many thanks

Colin

__________________________________________________ _______________
Want to block unwanted pop-ups? Download the free MSN Toolbar now!
http://toolbar.msn.co.uk/


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
- --
UC

- --
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFBguJDjqGXBvRToM4RArh0AJ46apSm5O/dX4QYJxuC44yyjYcWHQCfZpMu
+UU1SoXolAFx7fEhMUUXp5w=
=GRUr
-----END PGP SIGNATURE-----


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend



Reply With Quote
  #4  
Old   
Russell Smith
 
Posts: n/a

Default Re: adding missing FROM-clause - 10-30-2004 , 01:09 AM



On Sat, 30 Oct 2004 01:42 am, C G wrote:
Quote:
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;

Instead
SELECT c1 FROM t2, t1 INNER JOIN t2 ON t2.c2 = t1.c2 WHERE t3.c3=t2.c3

OR

SELECT c1 FROM t1 INNER JOIN t2 ON t2.c2 = t1.c2 JOIN t3 ON t3.c3 = t2.c3

Quote:
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.

Many thanks

Colin

__________________________________________________ _______________
Want to block unwanted pop-ups? Download the free MSN Toolbar now!
http://toolbar.msn.co.uk/


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.