多类型查询
来源:互联网 发布:数据标准化方法比较 编辑:程序博客网 时间:2024/06/06 00:19
<select id="getByCondition" resultMap="BaseResultMap">
SELECT
sm.id id,
sm.scene_id scene_id,
sm.name name,
sm.unit unit,
sm.relation_id relation_id,
sm.relation_type relation_type,
sm.icon icon,
sm.description description,
sm.device_name device_name,
sm.create_time create_time,
sm.last_update_time last_update_time,
sm.last_update_account last_update_account
FROM sm_monitorpoint sm
LEFT JOIN dm_virtualdeviceparam dvp ON sm.relation_id=dvp.id
LEFT JOIN dm_virtualdevice dv ON dv.id=dvp.device_id
WHERE relation_type=#{relationType}
<if test="deviceTypeList!=null and deviceTypeList.size>0">
AND dv.device_type_id IN
<foreach collection="deviceTypeList" separator="," open="(" close=")" index="index">
#{deviceTypeList[${index}]}
</foreach>
</if>
<if test="sceneIdList!=null and sceneIdList.size>0">
AND sm.scene_id IN
<foreach collection="sceneIdList" separator="," open="(" close=")" index="index">
#{sceneIdList[${index}]}
</foreach>
</if>
<if test="keywords!=null and keywords!=''">
AND (sm.name LIKE CONCAT('%',#{keywords},'%'))
</if>
</select>
SELECT
sm.id id,
sm.scene_id scene_id,
sm.name name,
sm.unit unit,
sm.relation_id relation_id,
sm.relation_type relation_type,
sm.icon icon,
sm.description description,
sm.device_name device_name,
sm.create_time create_time,
sm.last_update_time last_update_time,
sm.last_update_account last_update_account
FROM sm_monitorpoint sm
LEFT JOIN dm_virtualdeviceparam dvp ON sm.relation_id=dvp.id
LEFT JOIN dm_virtualdevice dv ON dv.id=dvp.device_id
WHERE relation_type=#{relationType}
<if test="deviceTypeList!=null and deviceTypeList.size>0">
AND dv.device_type_id IN
<foreach collection="deviceTypeList" separator="," open="(" close=")" index="index">
#{deviceTypeList[${index}]}
</foreach>
</if>
<if test="sceneIdList!=null and sceneIdList.size>0">
AND sm.scene_id IN
<foreach collection="sceneIdList" separator="," open="(" close=")" index="index">
#{sceneIdList[${index}]}
</foreach>
</if>
<if test="keywords!=null and keywords!=''">
AND (sm.name LIKE CONCAT('%',#{keywords},'%'))
</if>
</select>
阅读全文
0 0
- 多类型查询
- SQL连接查询类型
- 各种类型的查询
- DataTime类型模糊查询
- 查询字典类型
- DNS查询类型列表
- DNS查询类型备注
- 查询表字段类型
- mysql查询类型转换
- Oracle查询字符集类型
- HR 人员类型 查询
- 时间类型模糊查询
- DNS查询类型
- Java - Elasticsearch查询类型
- mybatis的查询类型
- golang中类型查询
- GO类型查询
- 数据库查询返回类型
- Python3 BeautifulSoup爬虫 ZOJ自动提交
- BaseAdapter 的使用实例
- [SCOI2007]压缩 区间dp
- mysql的5中查询子句之四order by排序查询
- 设计模式(对象创建)——原型模式
- 多类型查询
- 决策树(补充)
- 统一接口开发架构,统一接口架构实现封装
- Eclipse.exe目录下有jre,为什么启动会报错?
- 细数linux内核里那些偏门的C语言语法(三) !!(x)
- StringUtils
- angularjs的$on、$emit、$broadcast
- DirectShow安装
- baiduMap