mysql: can I do a for-each on a comma separated field?

Posted by Tillebeck on Stack Overflow See other posts from Stack Overflow or by Tillebeck
Published on 2010-04-20T12:26:17Z Indexed on 2010/04/20 12:33 UTC
Read the original article Hit count: 320

Filed under:
|
|
|

Just ran into a problem

I know these integers, $integers: 3,5,15,20

I only want to select the rows from this following table where all comma separated INT's from the field NUMBERS are found.

TABLE: number_table
Uid Numbers
------------------------
1   3,5,15    OK, since all of NUMBERS are in $integers
2   5,15,20   OK, since all of NUMBERS are in $integers
3   3,4,5,15  NOT OK, since 4 is not found in $integers
4   2,15,20,25  NOT OK, since 2 and 25 is not found in $integers

Is it possible to to a "for-each" on a comma separated string or another way to do this SELECT?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about select