1.通过多个逗号分隔的id,查询出对应的名字,并以逗号分隔返回
SELECT GROUP_CONCAT(user_name) AS name FROM userTable WHERE FIND_IN_SET(user_id,'1,2,3,6');
查询结果
name |
---|---
小明,小红,小亮 |
2.常用筛选条件
<if test="ui_status != null and ui_status != ''">
AND ui.ui_status = #{ui_status}
</if>
<if test="start_date_condition != null">
AND DATE_FORMAT(sa.sa_createdate,'%Y-%m-%d') >= DATE_FORMAT(#{start_date_condition},'%Y-%m-%d')
</if>
<if test="end_date_condition !=null">
AND DATE_FORMAT(sa.sa_createdate,'%Y-%m-%d') <= DATE_FORMAT(#{end_date_condition},'%Y-%m-%d')
</if>
<if test="keyword_condition !=null and keyword_condition !=''">
AND CONCAT(IFNULL(ui.ui_name,''),
IFNULL(dept.dept_name,''),
IFNULL(ui.ui_graduated_major,''))
LIKE CONCAT('%', #{keyword_condition}, '%')
</if>
网友评论