mybatis动态SQL
来源:互联网 发布:日本军工 知乎 编辑:程序博客网 时间:2024/05/16 14:50
很多人已经把动态sql介绍过了。下面我只说一个小坑 。希望大家不要踩。
<select id="queryCarInfo" parameterType="com.huanqiu.car.pojo.CarPage" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from Car car, Carteam team, CarSection cs, Cartype carType, Section sec <where> car.Carteam_id = team.Carteam_id AND cs.Car_id = car.Car_id AND sec.Section_id =cs.Section_id and car.Cartype_id=carType.Cartype_id <if test="carType != null"> and car.Cartype_id=#{carType} </if> <if test="carNumber != null"> and car.Car_number =#{carNumber} </if> </where> </select>
上面这是一个完整的代码块。
其中
<if test="carNumber != null"> and car.Car_number =#{carNumber} </if>
为动态SQL
注意点为:
<if test="#{carNumber != null}"> and car.Car_number =#{carNumber} </if>
是错误的。虽然不报错。但是这样会把下面的一直输出
and car.Car_number =#{carNumber}
其他的也就没有什么了。 mybatis的动态SQL还是很好用的。
阅读全文
0 0
- mybatis动态SQL语句
- MyBatis动态SQL
- MyBatis 动态SQL
- Mybatis 动态SQL
- MyBatis动态SQL
- MyBatis动态SQL完整版
- mybatis动态sql
- mybatis动态SQL语句
- mybatis动态SQL语句
- MyBatis的动态SQL
- MyBatis动态SQL
- MyBatis动态SQL
- MyBatis 动态SQL语句
- MyBatis动态SQL
- Mybatis组建动态SQL
- MyBatis 动态sql
- mybatis 动态SQL语句
- MyBatis动态SQL详解
- 要出去工作了
- 使用Bootstrap编写一个简单的网页轮播图效果
- 转:授之于鱼还是授之以渔,金蝶给了企业SaaS一个完整答案
- C#反射
- java浅拷贝(shallow clone)与深拷贝(deep clone)
- mybatis动态SQL
- HDU 1846-Brave Game
- 一种采用指针的指针的方式的建立链表的方法
- Hibernate
- for/while和$*之间
- SpringMVC
- Ferguson博弈
- MATLAB拟合工具箱 cftool 用法
- TCP/IP_3次握手4次分手