@Query(nativeQuery = true,value = "SELECT a.id , e.created_date FROM jg_bed a,jg_checkin_bed b ,jg_checkin c , jg_elder d, jg_checkout e WHERE a.id = b.bed_id and b.checkin_id = c.id and c.elder_id = d.id and d.id = e.elder_id and c.usage = ?1 and c.move_in_status =?2 and a.tenant_id = ?3 " + " <if test='queryData != null'> " + " and e.checkout_date between = #{queryData.bedCheckOutStartTime} and #{queryData.bedCheckOutEndTime}" + " and a.bed_status = #{queryData.bedStatus} " + "</if>") List<Map<String,String>>getCheckOutTimeAndBedId(String usage, String moveInStatusCheckOutDoing , String tenantId, @Param("queryData") QueryData queryData);有问题么 请改正
时间: 2024-03-27 22:36:58 浏览: 168
zzclient--6-8.rar_Java 8_LBS_android LBS
在这个查询语句中,使用了 MyBatis 的动态 SQL,但是 `<if>` 标签中的语句不完整,应该将 `between` 和 `=` 分开,并且 `=` 后面应该是 `#{queryData.bedCheckOutEndTime}` 而不是 `#{queryData.bedCheckOutStartTime}`。正确的语句应该是:
```
SELECT a.id, e.created_date
FROM jg_bed a, jg_checkin_bed b, jg_checkin c, jg_elder d, jg_checkout e
WHERE a.id = b.bed_id
AND b.checkin_id = c.id
AND c.elder_id = d.id
AND d.id = e.elder_id
AND c.usage = #{usage}
AND c.move_in_status = #{moveInStatusCheckOutDoing}
AND a.tenant_id = #{tenantId}
<if test='queryData != null'>
AND e.checkout_date BETWEEN #{queryData.bedCheckOutStartTime} AND #{queryData.bedCheckOutEndTime}
AND a.bed_status = #{queryData.bedStatus}
</if>
```
阅读全文