<select id="selectAll" resultMap="tblTicketCardDistributionMap"> select * from TBL_TICKET_CARD_DISTRIBUTION <where> <choose> <when test="query.orderType != null and query.orderType != '' and query.orderType =='03'"> and ORDER_TYPE = #{query.orderType} and ( <if test="query.inStationId != null and query.inStationId != '' "> IN_STATION_ID = #{query.inStationId} </if> <if test="query.outStationId != null and query.outStationId != '' "> or OUT_STATION_ID = #{query.outStationId} </if> ) </when> <otherwise> <if test="query.orderType != null and query.orderType != '' "> and ORDER_TYPE = #{query.orderType} </if> <if test="query.inStationId != null and query.inStationId != '' "> and IN_STATION_ID = #{query.inStationId} </if> <if test="query.outStationId != null and query.outStationId != '' "> or OUT_STATION_ID = #{query.outStationId} </if> </otherwise> </choose> <if test="query.lineId != null and query.lineId != '' "> and LINE_ID = #{query.lineId} </if> <if test="query.stationId != null and query.stationId != '' "> and STATION_ID = #{query.stationId} </if> <if test="query.operatorId != null and query.operatorId != '' "> and OPERATOR_ID = #{query.operatorId} </if> <if test="query.curDay != null and query.curDay != '' "> and CUR_DAY = #{query.curDay} </if> <if test="query.beginTime != null and query.beginTime != '' "> and OPERATE_TIME between #{query.beginTime} and #{query.endTime} </if> </where> </select>报错语法有问题,修改正确的
时间: 2024-03-18 19:42:12 浏览: 94
MyBatis学习-映射文件标签篇(select、resultMap).rar_alikeett_blueaod_mybatis
根据报错信息,需要看一下具体是哪个语法有问题。不过根据代码,有一个语法问题:
在`<when>`标签中,使用了`<if>`标签,应该改为`${}`,例如:
```
<when test="query.orderType != null and query.orderType != '' and query.orderType =='03'">
and ORDER_TYPE = #{query.orderType} and (
${query.inStationId != null and query.inStationId != '' ? 'IN_STATION_ID = #{query.inStationId}' : ''}
${query.outStationId != null and query.outStationId != '' ? ' or OUT_STATION_ID = #{query.outStationId}' : ''}
)
</when>
```
这样应该就能解决语法问题了。
阅读全文