Garayed.com  

Go Back   Garayed.com > Oracle
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-07-2007, 07:35 AM
colmkav
 
Posts: n/a
Default subqueries

Hi, I am trying to join the results from one select statement with 2
other tables and am not sure of the syntax. What comes natural doesnt
seem to work:

ie

SELECT * FROM tableC,
(select columnA, columnB.....
from table A, table B.....
where "TableA.fieldA = tableB.fieldA AND ......),
WHERE (tableC.fieldA = tableA.fieldB) AND (tableC.fieldB =
tableB.fieldB);

how can this be written? I could create a temporary table to replace
the select query in brackets but this seems a bit longwinded.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-07-2007, 08:18 AM
sybrandb
 
Posts: n/a
Default Re: subqueries

On Jun 7, 9:35 am, colmkav <colmj...@yahoo.co.uk> wrote:
> Hi, I am trying to join the results from one select statement with 2
> other tables and am not sure of the syntax. What comes natural doesnt
> seem to work:
>
> ie
>
> SELECT * FROM tableC,
> (select columnA, columnB.....
> from table A, table B.....
> where "TableA.fieldA = tableB.fieldA AND ......),
> WHERE (tableC.fieldA = tableA.fieldB) AND (tableC.fieldB =
> tableB.fieldB);
>
> how can this be written? I could create a temporary table to replace
> the select query in brackets but this seems a bit longwinded.


This is not a subquery, but an inline view.
Inline views need to be aliased (so outside the closing ')' ) and the
where clause needs to refer to the view alias so
SELECT * FROM tableC,
(select columnA, columnB.....
from table A, table B.....
where "TableA.fieldA = tableB.fieldA AND ......) view_alias --
Note I removed the redundant ,
WHERE (tableC.fieldA = view_alias.columnB) AND (tableC.fieldB =
view_alias.columnB);

--
Sybrand Bakker
Senior Oracle DBA

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:51 AM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.