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>
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>
相关文章推荐
- left join 过滤条件写在on后面和写在where 后面的区别
- asp.net MVC EF Where 过滤条件怎么写
- MyBatis 中 where 条件的 书写格式
- SQL中过滤条件放在on和where中的区别
- MyBatis的Where条件查询
- 关于C#中关于List.where中过滤条件的使用注意事项
- thinkphp where条件预处理过滤的占位符含义
- MyBatis动态sql_where查询条件
- Mybatis 不确定条件查询(动态语句where和if)借助实体类封装参数
- left join 过滤条件写在on后面和写在where 后面的区别
- mybatis模糊查询--前台传过来一个字符串,然后将这个字符串作为where条件进行模糊查询
- sql的where条件中包含中文,查询不出来的处理方法
- left join 过滤条件写在on后面和写在where 后面的区别
- Mysql下SELECT的结果集作为UPDATE的WHERE条件时的SQL语法
- Mysql下SELECT的结果集作为UPDATE的WHERE条件时的SQL语法
- 安全化mysql的where条件输入拼接面板:用于给不会mysql语法的操作人使用
- 工作总结 sql 中过滤条件 中的 (where中的) and
- sql总结之 被作为where过滤条件的字段 ,其值也是可以被更新的
- 数据库查询实例(包含所有where条件例子)
- LinqDataSource.Where中如何使用Contains查询包含双引号(")的条件