mysql find_in_set 函数 使用方法

mysql> select * from user;
+------+----------+-----------+
| id   | name     | address   |
+------+----------+-----------+
|    2 | xiaobai  | shandong  |
|    3 | xiaohong | suzhou    |
|    4 | xiaohei  | changchun |
|    1 | xiaoming | beijing   |
+------+----------+-----------+
4 rows in set (0.00 sec)


mysql> select * from user where find_in_set(cast(id as char),"1,2,3");
+------+----------+----------+
| id   | name     | address  |
+------+----------+----------+
|    2 | xiaobai  | shandong |
|    3 | xiaohong | suzhou   |
|    1 | xiaoming | beijing  |
+------+----------+----------+
3 rows in set (0.00 sec)

参考:

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

原文地址:https://www.cnblogs.com/sea-stream/p/11330087.html