Re: explode in mysql query
| From: | Sebe | Date: | Fri, 27 Apr 2007 07:59:49 +0000 |
| Subject: | Re: explode in mysql query | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-253951@lists.php.net to get a copy of this message | ||
Paul Novitski wrote:
At 4/26/2007 11:33 PM, Sebe wrote: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)i have a mysql column that looks like this: groups ------- 12,7,10,6,14,11,2 is it possible to select the row ifI 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:groupscontain 7 or 14? trying to avoid running two queries and running explode() on it.,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(',',Regards, Paulgroups, ',') LIKE '%,7,%' OR CONCAT(',',groups, ',') LIKE '%,14,%'