select * from user where id IN
(
SELECT substring_index('1,2,3',',', 1) union
SELECT substring_index(substring_index('1,2,3',',', -2), ',', 1) union
SELECT substring_index(substring_index('1,2,3',',', -1), ',', 1)
(
SELECT substring_index('1,2,3',',', 1) union
SELECT substring_index(substring_index('1,2,3',',', -2), ',', 1) union
SELECT substring_index(substring_index('1,2,3',',', -1), ',', 1)
)
SUBSTRING_INDEX(str, delim, count)
str: 要处理的字符串
delim: 分割符
count: 计数 如果为正数,则从左开始数,如果为负数,则从右开始数
虽然能实现效率很慢 追求效率,不推荐