Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003
    Posts
    43

    Unanswered: Using varchar column as argument to IN ()

    I've got a varchar column which contains values like "123, 234, 345" and I'd like to use this value as the argument to IN (). If I specify the values like this:

    WHERE foo IN (1,2,3)

    ... everthing works fine, but when I try to use a column:

    WHERE foo IN (varchar_column_containing_comma-delimited_numbers)

    ... it doesn't work as expected. What am I doing wrong?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    to answer your question: use FIND_IN_SET function

    to give you good advice: never store a list of ids in a single column
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Mar 2003
    Posts
    43
    Quote Originally Posted by r937
    to answer your question: use FIND_IN_SET function
    It works, but my god it's slow...

    Quote Originally Posted by r937
    to give you good advice: never store a list of ids in a single column
    I'm well aware, but I need a quick and dirty solution at the moment.

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •