Joining troubles

  • Hi Guys

    I have got two table as below

    Table 1

    Tests Patient_id date

    qw 1 1/2/2000

    wewe 2 1/12/2005

    cdd 1 12/03/2008

    .

    .

    bfs 3 13/12/2004

    ddd 2 01/01/2003

    Table 2

    Patient_id

    1

    2

    3

    34

    666

    8888

    I want to display the records from table 1 of those patients where patient_id of table 1 matches with the patient_id of table 2

    Cheers

  • This should work.

    SELECT T1.Tests, T1.Patient_Id, T1.Date from Table1 T1

    Inner Join Table2 T2

    ON T1.Patient_ID = T2.Patient_ID


    Bru Medishetty

    Blog -- LearnSQLWithBru

    Join on Facebook Page Facebook.comLearnSQLWithBru

    Twitter -- BruMedishetty

  • Nuts (12/6/2009)


    I want to display the records from table 1 of those patients where patient_id of table 1 matches with the patient_id of table 2

    Based soley on the question, I strongly recommend you visit the following website...

    http://www.w3schools.com/sql/default.asp

    --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 3 posts - 1 through 2 (of 2 total)

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