Select and Update a Column Value with data from another table

  • Hi,

    I have three tables

    T1 has the columns Course, Site and Roomid.

    T2 that has the same columns.

    T3 that has columns RoomId and Room Name

    I want to populate T2 with the values from T1 . For the Course and the Site the values can be automatically populated by using a Select and Insert statement. But the Roomid column in T2 should have the RoomName column data from T3.

    (Eg : T2. Roomid= T3.Roomname where T1.Roomid=T3.Roomid)

    How can I do this using a Select Query Only

    ie, Select Query and Select Subquery

    Help is appreciated.

    Thanks

  • Is this what you have in mind?

    SELECT T1.Course

    , T1.Site

    , T3.Room_Name

    FROM T1

    JOIN T3 ON T1.Roomid = T3.RoomId

    Have a look at JOIN http://msdn.microsoft.com/en-us/library/ms191517.aspx

    Also, you may want to look at views, to replace your T2 table.

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

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

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