SQL Language (MOSC)

MOSC Banner

Squence of Joining & Filtering

edited Aug 19, 2012 11:34PM in SQL Language (MOSC) 2 commentsAnswered
Assume that there are 2 tables, TABLE1 & TABLE2. There are COLUMN1, a column, in them respectively.
TABLE1             TABLE2
COLUMN1          COLUMN1
1                        1
2                        3
After running
select *
 from TABLE1 a left join TABLE2 b
 on a.COLUMN1=b.COLUMN1
 where b.COLUMN1 is NULL;
,
the results are
2                        NULL
Hence, database servers are deduced to join tables 1st. Then it filters the records according to the condition. If the sequence was reversed, the results would be following.
1                        NULL
2                        NULL


select *
 from (
            select *
            from TABLE3
            where COLUMN2='Test1'
          ) a
 inner join
 select *
 from (
            select *
            from TABLE4
            where COLUMN3='Test2'
          ) b
 on a. COLUMN1=b.COLUMN1;

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center