是的,您可以使用MySQL FIND_IN_SET()搜索特定编号。让我们首先创建一个表-
mysql> create table DemoTable ( ListOfNumbers varchar(100) );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values('784,746,894,344'); mysql> insert into DemoTable values('456,322,333,456'); mysql> insert into DemoTable values('654,785,678,456'); mysql> insert into DemoTable values('123,676,847,785');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
这将产生以下输出-
+-----------------+ | ListOfNumbers | +-----------------+ | 784,746,894,344 | | 456,322,333,456 | | 654,785,678,456 | | 123,676,847,785 | +-----------------+ 4 rows in set (0.00 sec)
以下是在记录中搜索特定数字的查询-
mysql> select *from DemoTable where find_in_set('456',ListOfNumbers);
这将产生以下输出-
+-----------------+ | ListOfNumbers | +-----------------+ | 456,322,333,456 | | 654,785,678,456 | +-----------------+ 2 rows in set (0.28 sec)