Home » SQL & PL/SQL » SQL & PL/SQL » FROM TABLE, SELECT (9i)
FROM TABLE, SELECT [message #312998] Thu, 10 April 2008 05:41 Go to next message
j0zele
Messages: 15
Registered: December 2006
Junior Member
Hi guys, I have a problem with a select

create table tab_1 (
field_1 number,
field_2 number);

create table tab_2 (
field_1 number,
field_2 number,
field_3 number,
field_4 number);

SELECT t1.field_1, res.field_1, res.field_2
from tab_1 t1, (SELECT t2.field_1, t2.field_2
              FROM tab_2 t2
               WHERE t2.field_3 = 1
                UNION
             SELECT t22.field_1, t22.field_2
              FROM tab_2 t22
               WHERE t.22field_3 = 2
               AND t.22field_4 = t1.field_2) res


This query doesnt work with the last condition t1.field_2, why??

Thanks
Re: FROM TABLE, SELECT [message #313005 is a reply to message #312998] Thu, 10 April 2008 05:55 Go to previous messageGo to next message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
Oracle can see an object it is included in the select statement or if the object is selected as part of outer select.

Regards

Raj
Re: FROM TABLE, SELECT [message #313011 is a reply to message #312998] Thu, 10 April 2008 06:19 Go to previous messageGo to next message
j0zele
Messages: 15
Registered: December 2006
Junior Member
thanks, but this doesnt solve my problem...

Any other idea??
Re: FROM TABLE, SELECT [message #313012 is a reply to message #312998] Thu, 10 April 2008 06:21 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
Quote:
This query doesnt work
Any chance you could be abit more descriptive?
Re: FROM TABLE, SELECT [message #313014 is a reply to message #312998] Thu, 10 April 2008 06:32 Go to previous messageGo to next message
j0zele
Messages: 15
Registered: December 2006
Junior Member
of course, ERROR ORA-00904 "t1.field_2" is not a valid identifier
Re: FROM TABLE, SELECT [message #313016 is a reply to message #313011] Thu, 10 April 2008 06:37 Go to previous messageGo to next message
Michel Cadot
Messages: 68737
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Raj gave you the root of the error, now you have to rewrite it to make it correct.
In other words, do the same thing but write it differently.

Regards
Michel
Re: FROM TABLE, SELECT [message #313029 is a reply to message #312998] Thu, 10 April 2008 07:35 Go to previous message
Frank
Messages: 7901
Registered: March 2000
Senior Member
Your table-alias is t22, yet your fieldname is t.22field1
How can we tell you didn't make up more lines or typos is your mock-up code?
Previous Topic: Help needed on an Analytical Query
Next Topic: Migrating testscript from MS SQLServer to Oracle
Goto Forum:
  


Current Time: Tue Feb 18 19:28:20 CST 2025