MySQL选择值在IN列表字符串中?
为此,请使用FIND_IN_SET()。
让我们创建一个表-
示例
mysql> create table demo81 -> ( -> id int not null auto_increment primary key, -> username varchar(200) -> );
以下是查询以选择值在IN列表字符串中的位置-
示例
mysql> select *from demo81 where find_in_set('Chris',username) > 0;这将产生以下输出-
输出结果
+----+------------------+ | id | username | +----+------------------+ | 1 | John,Chris,David | | 3 | Chris,Bob,Sam | | 4 | Mike,John,Chris | +----+------------------+ 3 rows in set (0.03 sec)
热门推荐
1 如何训练狗狗不叫
2 训练狗狗不叫
3 训练狗狗随行
4 怎么训练狗狗不叫
7 训练比熊狗狗教程
10 上海狗狗训练
11 怎么训练狗狗上厕所
12 训练狗狗趴下
13 狗狗服从训练
14 训练狗狗拒食
15 训练狗狗笑
16 训练狗狗大便
17 训练狗狗立
18 训练狗狗捡东西