Urgent: FIND_IN_SET troubles

Discussion in 'MySQL' started by atxsurf, Jul 29, 2012.

  1. #1
    So I have a 'set' type field of 3 values in my database and the records of that field like:
    field
    1,2,3
    1,2,3
    1,2
    2,3
    2
    1,3

    if I "select field where FIND_IN_SET(2, field)" it returns as expected:
    1,2,3
    1,2,3
    1,2
    2,3
    2

    but if I "select field where field=2" it does not return anything!
    How do I get that '2' only record without using AND NOT FIND_IN_SET(1, field) AND NOT FIND_IN_SET(3, field)
     
    atxsurf, Jul 29, 2012 IP
  2. atxsurf

    atxsurf Peon

    Messages:
    2,394
    Likes Received:
    21
    Best Answers:
    1
    Trophy Points:
    0
    #2
    figured it out myself - needed single quotes around the value like:
    select field from table where field='2'
     
    atxsurf, Jul 29, 2012 IP