Select Statement

Discussion in 'PHP' started by adamjblakey, Nov 13, 2007.

  1. #1
    Hi,

    Can you do an sql select statement that based on things that it should not contain e.g.

    SELECT * FROM table WHERE country = 'United Kingdom' LIMIT 0 , 5

    Basically i want the opposite to this statement which accepts anything but United Kingdom.

    Sorry if i have not explained in properly.

    Cheers,
    Adam
     
    adamjblakey, Nov 13, 2007 IP
  2. greatlogix

    greatlogix Active Member

    Messages:
    664
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    85
    #2
    SELECT * FROM table WHERE country <> 'United Kingdom' LIMIT 0 , 5
     
    greatlogix, Nov 13, 2007 IP
  3. indy2kro

    indy2kro Peon

    Messages:
    11
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    SELECT * FROM table WHERE country != 'United Kingdom' LIMIT 0 , 5

    Works as well.
     
    indy2kro, Nov 13, 2007 IP
  4. adamjblakey

    adamjblakey Active Member

    Messages:
    1,121
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    #4
    Thanks for that, say if i wanted this to work on both United Kingdom and also South Africa how would i go about that?
     
    adamjblakey, Nov 13, 2007 IP
  5. greatlogix

    greatlogix Active Member

    Messages:
    664
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    85
    #5
    SELECT * FROM table WHERE country <> 'United Kingdom' AND country <> 'South Africa' LIMIT 0 , 5
     
    greatlogix, Nov 13, 2007 IP
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
    Or

    
    SELECT * FROM table_name WHERE country NOT IN('United Kingdom', 'South Africa') LIMIT 0 , 5
    
    Code (sql):
     
    nico_swd, Nov 13, 2007 IP