我正在尝试编写一个选择查询以在特定列中搜索字符串。
例如:
+----+------+-------------------------------+
| id | name | alternate |
+----+------+-------------------------------+
| 1 | Test | Test,Tests,test,tests,te,test |
| 2 | Demo | Demo.demo,dem,Dem |
+----+------+-------------------------------+
等...
我只是想编写一个查询来检查列名替代中提交的值名称
例如:我将提交名称测试,它应该检查包含的列名称是否存在
最佳答案
$query = SELECT * FROM tablename WHERE FIND_IN_SET('test', alternate);
if(mysql_num_rows($query) > 0){
//if test was found
} else {
// test not found
}
更多信息here
关于php - 使用 MySQL 查询在列名中查找字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22164137/