SELECT t.id,t.accident_Title,t.happen_Time,t.accident_Adr,t.accident_Type,t.death_Num,t.economic_Losses,t.catalog_Id, t1.name AS accident_Type_Name FROM tb_resources_case t LEFT JOIN (select d.name,d.id from tb_sys_dict_tree d where d.is_delete='0' and d.code='accidentType') t1 ON t.accident_Type = t1.id WHERE t.is_delete='0'<if test="model.beginTime != null and model.beginTime!='' "> and substr(t.happen_Time,0,10)>=#{model.beginTime} </if> <if test="model.endTime != null and model.endTime!='' "> AND substr(t.happen_Time,0,10)<=#{model.endTime} </if>这段语句有什么错?怎么解决
时间: 2024-03-08 09:51:02 浏览: 104
这段语句在逻辑上没有错误,但是在语法上有一个小问题。在第6行的代码中,`<=`应该被替换为`<=`,因为`<`是HTML实体代表小于号(`<`),而在这里它应该被解释为小于等于号(`<=`)。所以正确的语句应该是:
```
SELECT t.id, t.accident_Title, t.happen_Time, t.accident_Adr, t.accident_Type, t.death_Num, t.economic_Losses, t.catalog_Id, t1.name AS accident_Type_Name
FROM tb_resources_case t
LEFT JOIN (SELECT d.name, d.id FROM tb_sys_dict_tree d WHERE d.is_delete='0' AND d.code='accidentType') t1
ON t.accident_Type = t1.id
WHERE t.is_delete='0'
<if test="model.beginTime != null and model.beginTime != ''">
AND substr(t.happen_Time, 0, 10) >= #{model.beginTime}
</if>
<if test="model.endTime != null and model.endTime != ''">
AND substr(t.happen_Time, 0, 10) <= #{model.endTime}
</if>
```
阅读全文