您的位置:首页 > 其它

mybatis语法包含where 包含连表,包含多条件,包含除法,包含过滤

2018-03-17 14:48 253 查看
<select id="selectDepartmentdoctor" parameterType="com.amenuo.yiliao.bean.departmentdoctorPO" resultType="com.amenuo.yiliao.bean.DoctorScorPo">
        SELECT
        usr.id,
        usr.realname,
        usr.user_img_url  userImgUrl,
        usr.longitude,
        usr.latitude,
        usr.begoodat,
        doc.Doctor_score/5 Doctorscore
        FROM
        tb_user_department dep
        LEFT JOIN tb_userdetail usr ON dep.user_id = usr.id
        LEFT JOIN tb_doctorscore doc ON doc.userid = usr.id
        LEFT JOIN tb_user us ON us.id=usr.id
        <where>
             dep.department_code = #{departmentcode}
            <if test="city !=null">
                AND usr.address LIKE  concat('%',#{city,jdbcType=VARCHAR},'%')
            </if>
            <if test="Frequency!=null">
                ORDER BY doc.Frequency DESC
            </if>
            <if test="Doctor_score!=null">
                ORDER BY doc.Doctor_score DESC
            </if>
            and  !ISNULL(usr.latitude) and !ISNULL(usr.latitude)  and us.delete_flag ='N'
        </where>

    </select>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: