Exotic join

  • I am trying to analyze the behavior of joins with theta operators. I have created two tables with single column.

    t1 t2

    -- ---

    a b

    b c

    c d

    d e

    e f

    f g

    I ran these queries

    1) select t1.col1,t2.col1 from t1 full outer join t2 on t1.col1 <> t2.col1

    results:

    col1col1

    a b

    a c

    a d

    a e

    a f

    a g

    b c

    b d

    b e

    b f

    b g

    c b

    c d

    c e

    c f

    c g

    d b

    d c

    d e

    d f

    d g

    e b

    e c

    e d

    e f

    e g

    f b

    f c

    f d

    f e

    f g

    2) select t1.col1,t2.col1 from t1 full outer join t2 on t1.col1 <> t1.col1

    col1col1

    a NULL

    b NULL

    c NULL

    d NULL

    e NULL

    f NULL

    NULLb

    NULLc

    NULLd

    NULLe

    NULLf

    NULLg

    I am unable to understand how this is getting executed internally.

    Can some body explain the internal execution of these T-SQL statements?


  • Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • chowdarysurendranath.c (2/1/2012)


    ...

    2) select t1.col1,t2.col1 from t1 full outer join t2 on t1.col1 <> t1.col1

    ...

    t1.col1 <> t1.col1

    this clause returns false for every row (is the same as 1 <> 1 or x <> x)

    So on for any t1 there's no t2 and vice-versa

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply