select problem

  • i have 3 tables like this

    t1 --->table1

    id name

    1 jj

    2 qq

    t2----->table2

    id name

    1 rr

    2 uu

    t3---table 3

    tableId tableName

    1 t1

    2 t2

    i need the foolwing result

    name

    jj

    uu

  • I'm sorry, but I don't understand the structure. What relates one table to another? How would you join table1 to table2 to get the results you want. What does table3 have to do with it?

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Completely wild guess at what you are trying to do

    Select

    Name =

    case T3.TableName

    When 'T1' then t1.name

    When 't2' Then t2.name

    End

    From t3

    inner join t1 on t1.id = t3.tableId

    Inner join t2 on t2.id = t3.tableId

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

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