Paul Novitski wrote:
At 4/26/2007 11:33 PM, Sebe wrote:
i have a mysql column that looks like this:

groups
-------
12,7,10,6,14,11,2

is it possible to select the row if `groups` contain 7 or 14?
trying to avoid running two queries and running explode() on it.


I would think a more efficient strategy would be a simple string search. If you append a comma to the beginning and the end of your list so it becomes:

        ,12,7,10,6,14,11,2,

then you can search for:

        ,#,

where # is the desired integer.

Therefore you could use the MySQL syntax:

        WHERE CONCAT(',', `groups`, ',') LIKE '%,7,%'
           OR CONCAT(',', `groups`, ',') LIKE '%,14,%'

Regards,

Paul

thanks for the idea.. i also just came up with a solution using mysql FIND_IN_SET

eg: FIND_IN_SET('7', groups) OR FIND_IN_SET('14', groups)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to