<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 20:42:12 浏览: 97
根据报错信息,需要看一下具体是哪个语法有问题。不过根据代码,有一个语法问题:
在`<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>
```
这样应该就能解决语法问题了。
相关问题
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.phonemarket.mapper.BannerMapper"> <resultMap type="Banner" id="BaseResultMap"> <id property="bannerId" column="banner_id" /> <result property="bannerName" column="banner_name" /> <result property="bannerUrl" column="banner_url" /> <result property="bannerImg" column="banner_img" /> <result property="bannerState" column="banner_state" /> </resultMap> <insert id="addBanner" parameterType="Banner"> insert into banner(banner_name,banner_url,banner_img) values(#{bannerName},#{bannerUrl},#{bannerImg}) </insert> <update id="deleteBanner" parameterType="java.lang.Integer"> update banner set banner_state=-1 where banner_id=#{id} </update> <update id="changeBannerState" parameterType="java.lang.Integer"> update banner set banner_state=#{0} where banner_id=#{1} </update> <update id="updateBanner" parameterType="Banner"> update banner <set> <if test="bannerName!=null"> banner_name=#{bannerName}, </if> <if test="bannerUrl!=null"> banner_url=#{bannerUrl}, </if> <if test="bannerImg!=null"> banner_img=#{bannerImg} </if> </set> where banner_id=#{bannerId} </update> <select id="findBannerById" parameterType="java.lang.Integer" resultMap="BaseResultMap"> select * from banner where banner_id=#{id} </select> <select id="findAllBanner" resultMap="BaseResultMap"> select * from banner where banner_state > 0 </select> <select id="findAllBannerByLikeName" parameterType="java.lang.String" resultMap="BaseResultMap"> select * from banner where banner_state > 0 and banner_name like '%${value}%' </select> <select id="findAllShowBanner" resultMap="BaseResultMap"> select * from banner where banner_state=1 </select> </mapper>
这是一个 MyBatis 的 XML 配置文件,用于映射 Banner 对象和 banner 数据库表之间的关系。文件中定义了一个 namespace 为 com.phonemarket.mapper.BannerMapper 的 Mapper,并包含了一些 SQL 语句,如插入、删除、更新和查询等。括号中的参数类型表示 SQL 语句中的参数类型,resultMap 定义了查询结果与 Banner 对象之间的映射关系。其中BaseResultMap是一个标识符,表示基本的结果映射,对应了Banner类中的属性名称。在 SQL 语句中,#{param} 表示参数占位符,${value} 表示变量占位符。
<select id="selectFundSettlementList" parameterType="FundSettlementEntity" resultMap="FundSettlementResult"> select * from t_fund_settlement <where> <if test="orderType != null and orderType != ''"> <if test="orderType=='other'"> and order_type not in ("issue_ticket","return_ticket","rebook_ticket") </if> <if test="orderType=='issue_ticket' or orderType=='return_ticket' or orderType=='rebook_ticket'"> and order_type = #{orderType} </if> </if> </where> order by bill_date_time desc </select>
这段代码是一个数据库查询语句的映射配置,用于根据条件从表t_fund_settlement中选择基金结算记录。它使用了MyBatis的动态SQL功能来根据不同的条件生成不同的查询语句。
在<where>标签中,它首先检查订单类型是否不为空且不为空字符串。如果满足这个条件,它会根据订单类型的取值生成不同的查询条件。
如果订单类型是"other",则添加一个条件:订单类型不是"issue_ticket"、"return_ticket"或"rebook_ticket"。
如果订单类型是"issue_ticket"、"return_ticket"或"rebook_ticket",则添加一个条件:订单类型等于订单类型的值。
最后,查询结果按照bill_date_time字段进行降序排序。
这段代码的作用是根据给定的条件从t_fund_settlement表中选择符合条件的基金结算记录,并按照指定字段进行排序。
阅读全文