mysql find_in_set 函数 使用方法

时间:2024-05-22 08:34:14
mysql> select * from user;
+------+----------+-----------+
| id | name | address |
+------+----------+-----------+
| | xiaobai | shandong |
| | xiaohong | suzhou |
| | xiaohei | changchun |
| | xiaoming | beijing |
+------+----------+-----------+
rows in set (0.00 sec) mysql> select * from user where find_in_set(cast(id as char),"1,2,3");
+------+----------+----------+
| id | name | address |
+------+----------+----------+
| | xiaobai | shandong |
| | xiaohong | suzhou |
| | xiaoming | beijing |
+------+----------+----------+
rows in set (0.00 sec)

参考:

https://www.cnblogs.com/flintlovesam/p/6832485.html