Home » SQL & PL/SQL » SQL & PL/SQL » Inner Sub Queries
Inner Sub Queries [message #199814] Thu, 26 October 2006 05:54 Go to next message
miroconnect@yahoo.com
Messages: 202
Registered: April 2006
Senior Member
I have confusion with inner queries.
Suppose I have two table
first table: as_events
cols are event_id, event_alias, display names
second table: as_trails:
cols are trail_id,event_id,object_id,user_id,date


Here is the query

(select * from as_event)event,
(select * from as_trail) trail
where event.evevnt_id=trail_event_id


Here is query with the same output as above but without inner queries

select from event.*,trail.* from as_event event ,as_trailtrail where event.event_id=trail_trail_id


I confused which is the better approach and why?
Thanks & Regards
miro
Re: Inner Sub Queries [message #199829 is a reply to message #199814] Thu, 26 October 2006 07:08 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
miroconnect@yahoo.com wrote on Thu, 26 October 2006 12:54
Here is query with the same output as above but without inner queries

select from event.*,trail.* from as_event event ,as_trailtrail where event.event_id=trail_trail_id


Same output as in both get a missing expression error?
Re: Inner Sub Queries [message #199836 is a reply to message #199814] Thu, 26 October 2006 07:27 Go to previous message
Kevin Meade
Messages: 2101
Registered: December 1999
Location: Connecticut USA
Senior Member
I think you terminology is a bit off.

First, you are missing the * as in "select *...". That is the cuse of the missing expression.

Second, both these queries are the same. Inner join is really a poor name of to begin with (I never liked it). In any event, in most situations, these queries will execute the same way because Oracle will do the necessary rewrite to make them the same. Indeed, semantically they mean the same thing.

I wouldn't put too much emphasis on the term "inner join", it isn't used that much, except that some bean counter couldn't handle the fact that we had an "outer join", so there must be something called an "inner join". I suppose so.

Good luck, Kevin
Previous Topic: generic way of insertion
Next Topic: Tablenames by SQL-Syntax
Goto Forum:
  


Current Time: Sat Dec 03 01:21:18 CST 2016

Total time taken to generate the page: 0.18638 seconds