mysql find_in_set

find_in_set(str1,str2) 函数:返回str2中str1所在的位置索引,其中str2必须以","分割开。

表:
mysql> select * from region;

+----+-------------+

| id | name               |

+----+-------------+

|  1  | name1,nam2  |

|  2  | name1             |

|  3  | name3       |

|  4  | name2,name4 |

|  5  | name3,name5 |

+----+-------------+

5 rows in set (0.00 sec)
 FIND_IN_SET语句 mysql> select * from test where find_in_set('name1',name); 
+----+------------+

| id | name            |

+----+------------+

|  1  | name1,nam2 |

|  2  | name1      |

+----+------------+

2 rows in set (0.02 sec)

你可能感兴趣的:(mysql)