Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Location
    South Africa
    Posts
    2

    Question Unanswered: select column value which is selected from a column of another table

    i need help to get the value of a column which is selected from a column of another table....

  2. #2
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    can you be more specific ... post some ddl and expalin what you mean ?
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  3. #3
    Join Date
    Jan 2004
    Location
    South Africa
    Posts
    2
    Originally posted by Enigma
    can you be more specific ... post some ddl and expalin what you mean ?

    Thanks Enigma....

    I AM explaining with the following example...

    Table ABC
    ----------------
    Col1 | Col2 | Col3
    ---------------------------------
    red | 30 | 10
    blue | 20 | 20


    Table XYZ
    -------------
    Red | Blue
    ------------------
    11 | 22

    this is just example to explain to u

    Now I want select the value of RED i.e 11 from the table XYZ but the column RED is selected from the Table ABC and I want store this value in a variable....

    so please give me a query to store that value in the variable

    i did like this ....but i am unable to store this value in the variable @val


    declare @val as char(14)
    declare @colname as char(20)


    set @colname= (select Col1 from ABC where Col3 = 10)

    exec('select ' + @colname + ' from XYZ ')

    it displaying the value 11 but i want to store that 11 value into the variable @val........
    please help me

    thanks
    komalla

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    What will you do with @val once you have the value stored ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •