mybatis中使用order by 排序

如果编码格式为utf-8型,并且需要为中文字段排序, 那么可以使用如下代码

<select id="selectGoodsManageList" parameterType="GoodsManage" resultMap="GoodsManageResult">
        <include refid="selectGoodsManageVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
          <!--   <if test="shopId != null "> and shop_id = #{shopId}</if>-->
            <if test="goodType != null  and goodType != ''"> and good_type = #{goodType}</if>
            <if test="state != null "> and state = #{state}</if>
        </where>
        // 这个里name为数据库字段名,可以直接使用
        order by CONVERT( name USING gbk ) COLLATE gbk_chinese_ci ASC
    </select>
posted @ 2022-04-03 19:17  正伯Pro  阅读(111)  评论(0)    收藏  举报  来源