Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 匹配mysql中拆分后的确切子字符串_Php_Mysql_Sql_Codeigniter - Fatal编程技术网

Php 匹配mysql中拆分后的确切子字符串

Php 匹配mysql中拆分后的确切子字符串,php,mysql,sql,codeigniter,Php,Mysql,Sql,Codeigniter,您好,我使用的是codeigniter,在数据库中,我的表名是posts,其中有一列countriesId,其中的值如下1、21、13、162、172、182、155 因此,在查询中,我希望拆分值1、21、13…,并匹配查询值 例如,如果我使用LIKE并询问countryID的记录“1”,它将匹配1、21、13,因为值中有“1”。如何在查询中断开字符串并匹配精确的整数 谢谢。您可以运行。因此您希望使用“在集合中查找”功能。我不知道您的数据库模式是什么样子的,但您的查询将是这样的 SELECT c

您好,我使用的是codeigniter,在数据库中,我的表名是posts,其中有一列countriesId,其中的值如下
1、21、13、162、172、182、155

因此,在查询中,我希望拆分值
1、21、13…
,并匹配查询值

例如,如果我使用LIKE并询问countryID的记录
“1”
,它将匹配
1、21、13,因为值中有“1”。如何在查询中断开字符串并匹配精确的整数


谢谢。

您可以运行。

因此您希望使用“在集合中查找”功能。我不知道您的数据库模式是什么样子的,但您的查询将是这样的

SELECT countries.*, posts.countriesId FROM posts, countries WHERE FIND_IN_SET(countries.countryID, posts.countriesId) AND posts.postId = '1'

请尝试
where column()
check here@krishna再次阅读问题