<select id="selectExecuteSqlDetail" resultType="com.cvte.model.entity.ExecuteSqlDetail"> SELECT s.product_id, s.mybatis_id, s.sql_template, s.count, s.t_id, s.version, d.consume_time, d.s_id, d.total_score, d.create_time FROM sql_template s JOIN sql_plan_detail d ON s.t_id = d.template_id WHERE s.product_id = #{productId} <if test="mybatisId != null"> AND s.mybatis_id = #{mybatisId} </if> <if test="version != null"> AND s.version = #{version} </if> <if test="startTime != null and endTime != null"> AND d.create_time BETWEEN #{startTime} AND #{endTime} </if> <if test="minScore != 0.0"> and d.total_score > #{minScore} </if> <if test="maxScore != 0.0"> and #{maxScore} > d.total_score </if> ORDER BY d.total_score DESC </select>
时间: 2024-04-27 11:24:55 浏览: 22
这是一段 MyBatis 的 SQL 查询语句,查询的是一个名为 sql_template 和一个名为 sql_plan_detail 的表的一些字段。其中,sql_template 表中的 product_id, mybatis_id, sql_template, count, t_id, version 字段和 sql_plan_detail 表中的 consume_time, s_id, total_score, create_time 字段被查询出来。查询条件包括 product_id、mybatis_id、version、startTime、endTime、minScore 和 maxScore。如果 mybatis_id 不为空,则会加上一个额外的条件。如果 version 不为空,则也会加上一个额外的条件。如果 startTime 和 endTime 不为空,则加上一个时间范围的条件。如果 minScore 和 maxScore 不为 0,则分别加上一个总分数的最小值和最大值的条件。最后,结果按照 total_score 降序排序。
相关问题
<select id="findByName" resultType="com.xujunfei.entity.UserInfo">
这是 MyBatis 中的一个 SQL 映射文件的 XML 标签,用于定义一个查询语句。其中,id 属性指定了这个查询语句的名称,resultType 属性指定了查询结果集的映射类型。在这个例子中,查询语句的名称是 findByName,查询结果集的映射类型是 com.xujunfei.entity.UserInfo。
<select id="getWeekTrend" resultType="java.lang.Integer" >
这是一段XML代码片段,用于定义一个名为"getWeekTrend"的查询语句。该查询语句返回一个Java整数类型的结果,使用默认的结果映射器将查询结果映射到Java对象中。在MyBatis框架中,resultType属性用于指定查询结果的类型,可以是Java基本数据类型、JavaBean或者Map等类型。