question about sql table

Discussion in 'PHP' started by ItamarP, Aug 26, 2009.

  1. #1
    i've created a table which includes the next columbns:
    a,b,c,d,e

    i want to write a "select" query which get o-n-l-y the information from "b" when a exists.

    can you plz help?


    thanks in advance
     
    ItamarP, Aug 26, 2009 IP
  2. p4n4d0l

    p4n4d0l Peon

    Messages:
    51
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    How about this:

    SELECT b FROM yourtablename WHERE b IS NOT NULL
     
    p4n4d0l, Aug 26, 2009 IP
  3. Amator

    Amator Well-Known Member

    Messages:
    1,424
    Likes Received:
    55
    Best Answers:
    0
    Trophy Points:
    165
    #3
    SELECT b FROM yourtablename WHERE a IS NOT NULL
     
    Amator, Aug 26, 2009 IP
  4. ItamarP

    ItamarP Member

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    there are a lot of a values and a lot of b values, and they are all different

    i hope you understood me now
     
    ItamarP, Aug 26, 2009 IP
  5. p4n4d0l

    p4n4d0l Peon

    Messages:
    51
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Can you give the sample of data, and give the result output that you want?
     
    p4n4d0l, Aug 26, 2009 IP
  6. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #6
    The SQL statement is on a per record basis, meaning that you'll get back a bunch of rows containing the value for b of that row, but only if the value a for that row is not null. So if 5 records match that condition, you'll get back 5 rows.
     
    kblessinggr, Aug 26, 2009 IP