------

[ AD ] Port Monitor ( Try to use a Best WebSite Monitoring Tool )

------

Outer Join

 

TABLE testF

acol      bcol

1         2

1         3

3         2

1         3001

 

TABLE testZ

bcol      ccol

2         2

3         2

 

 

Inner join : testF-testZ on bcol column

 

select a.*,b.bcol as result from testF a

inner join testZ b

on a.bcol = b.bcol

 

acol      bcol      result

1         2         2

1         3         3

3         2         2

 

Will be result ,

 


 

Outer join : testF-testZ on bcol column – check isnull

 

MySQL/MSSQL 공통 방식

select a.*,

CASE

        WHEN b.bcol IS NULL THEN 0

        ELSE 1

END

from testF a

left outer join testZ b

on a.bcol = b.bcol

acol      bcol      (No column name)

1         2         1

1         3         1

3         2         1

1         3001     0

 

MSSQL 방식 : isnull

select a.*,

CASE isnull(b.bcol, 0)

        WHEN 0 THEN 0

        ELSE 1

END

from testF a

left outer join testZ b

on a.bcol = b.bcol

 

acol      bcol      (No column name)

1         2         1

1         3         1

3         2         1

1         3001     0

 

 

+ Recent posts