表格arts
列标签
- 示例:
天空、代码、地球、codepen
$tag = 'code';
$sql = "select * from arts where tags like ('%" . $tag . "%')";
结果 - 代码,codepen
我只需要结果中的code
,即类似这样的内容:
$sql = "select * from arts where tags contains only (' . $tag . ')";
有什么帮助吗?
最佳答案
您可以使用 FIND_IN_SET 检查 CSV 列中的值。
$sql = "select * from arts where FIND_IN_SET('" . $tag . "', tags)";
关于php - 选择包含确切字符串的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56179858/