joins

  • hai,

    one more ques

    suppose u have two tables

    in first table 15 rows and in the second table 10 rows

    there is a col named ID which is common to both the tables and some of the values in this col are common

    now u hav to write a querry which gives the values of rows which r not common to both tables

  • FULL OUTER JOIN with null detectors on both tables.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • thank u jeff

    can u provide me the script

  • If we did that, you might think it was easy! Have a go at writing it yourself, and post back if there's any particular aspect you don't understand.

    John

  • Use Books Online to get an example. How can we write you a query if we don't know your table schema? Anything else would be an example derived from the authors head. Why not save everyone time and use BOL to get a working example from a Microsoft test DB where you can at least play with it and get to understand how it works?

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • swathichilukuri85 (3/18/2008)


    thank u jeff

    can u provide me the script

    The others are correct... We can't write a script for your tables because you haven't posted them or any sample data. Please click on the URL in my signature line for more information on that. Do read the article and try the code... it will be a great help to you in future postings...

    Also, Books Online is, or should be, your best friend for stuff like this. If you look in the index for FULL OUTER JOIN, you'll find the following URL (past it into the URL field of the Books Online screen) ... and it has examples using the Adventure Works database that comes with SQL Server...

    ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/58855df5-6620-479d-b662-611e94ce8e2b.htm

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • thank u all

    i got it solved

  • Perfect... the next thing to do would be to practice a little of what we call "forum etiquette"... 😉 How did you solve it and would you mind posting the code, please?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • sorry it was late to get back with the solution

    but here is it

    use <database name?

    go

    -- The OUTER keyword following the FULL keyword is optional.

    SELECT p.Name, sod.SalesOrderID

    FROM Production.Product p

    FULL OUTER JOIN Sales.SalesOrderDetail sod

    ON p.ProductID = sod.ProductID

    WHERE p.ProductID IS NULL

    OR sod.ProductID IS NULL

    ORDER BY p.Name ;

    the column names are my table regarding so u can change them accordingly

    once again thanks everybody

  • Thanks...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 10 posts - 1 through 9 (of 9 total)

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