Select data from a table

Discussion in 'Databases' started by ItamarP, Aug 28, 2009.

  1. #1
    i've created a table with the following columns :
    a,b,c

    the values in "a" are 1,2,3,4,5 (for example)
    the values in "b" are 6,7,8,9,10 (for example)
    the values in "c" are 11,12,13,14,15 (for example,again)

    the table looks that way
    a b c
    ______
    1 6 11
    2 7 12
    3 8 13
    4 9 14
    5 10 15

    let's look on the second line, and imagine that the user selected "2"
    i need a code that gets only "7" when "2" exists (which means that 12 is meanless in that case)



    thanks in advance
     
    ItamarP, Aug 28, 2009 IP
  2. plog

    plog Peon

    Messages:
    298
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #2
    SELECT b FROM tablename WHERE a=2;
     
    plog, Aug 28, 2009 IP
  3. taarzan

    taarzan Active Member

    Messages:
    240
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #3
    a more precise query would be select b from tablename where a = value .If u want the value to be chosen on run time use this one .
     
    taarzan, Aug 28, 2009 IP
  4. yuvrajm

    yuvrajm Peon

    Messages:
    52
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    try using split, am not able to place much logic on this at this moment, but I have done this months back in a project
     
    yuvrajm, Sep 1, 2009 IP