发新话题
打印

mysql in类型参数字符串数据处理

mysql in类型参数字符串数据处理

SELECT * FROM user WHERE fk_class_id IN ("1,2") ;  // 3条数据,少了2班的1条数据
SELECT * FROM user WHERE fk_class_id IN (1,2) ; // 不带引号,正常4条数据
SELECT * FROM user WHERE FIND_IN_SET(fk_class_id,"1,2"); // 使用FIND_IN_SET 代替 IN ,正常4条数据

SELECT
eu.id,
eu.name,
eu.skill,
(SELECT GROUP_CONCAT(l.lottery_name) FROM bbx_lottery l WHERE FIND_IN_SET(l.lottery, eu.skill)) lotteryNames,
eu.feedback,
eu.passed,
eu.up_type upType,
eu.add_time addTime
FROM bbx_expert_up eu
<where>
eu.user_id = #{userId}
ORDER BY eu.add_time DESC
</where>

TOP

发新话题