且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MySQL将逗号分隔的字段与单个字符串进行比较

更新时间:2023-01-29 15:02:37

对于这种简单的情况,您可以使用 FIND_IN_SET() ;

For this simple case you can use FIND_IN_SET();

WHERE FIND_IN_SET('13', schools);

请注意,对于用逗号分隔的文本列没有很好的索引编制,因此查询将是比规范化数据库慢很多。

Note though that there is no good indexing for columns with comma separated text, so the queries will be much slower than a normalized database.