Select from mysql?

Discussion in 'PHP' started by t3od0r, Sep 7, 2009.

  1. #1
    Hello, i need a little help,
    i have this table in mysql:
    Table Name: files
    Field                            Type             
    ---------                  ---------  
    id                              int(11)    
    name                         varchar(155)  
    url                             varchar(155)      
    in                              text     
    
    
    Data: files
    id     name        url             in
    --   ------       ----      -------------
     1     file 1        url1        1,2,3,5,6
     2     file 2        url2        2,4,5,1,9
     3     file 3        url3        1,3,9
     4     file 4        url4        3,5,6,7
    
    Code (markup):
    Now I want to select only the rows that have '9' in the 'in' field

    i want to know if i can select from just one query

    Can anyone help me out in this ?
     
    t3od0r, Sep 7, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    select * from files where `in` LIKE '%,9,%' OR `in` LIKE '%,9' OR `in` LIKE '9,%' OR `in` LIKE '9'
    Code (markup):
     
    premiumscripts, Sep 7, 2009 IP
  3. t3od0r

    t3od0r Well-Known Member

    Messages:
    334
    Likes Received:
    3
    Best Answers:
    3
    Trophy Points:
    155
    #3
    Thanks a lot :)
     
    t3od0r, Sep 7, 2009 IP