mybatis 查询小结
来源:互联网 发布:网络用语 丫丫 编辑:程序博客网 时间:2024/06/14 06:58
mybatis 查询
一、模糊查询:
(1)sql字符串拼接
select * from t_user where name like CONCAT(CONCAT('%',#{name},'%'))
(2)使用${...}代替#{...}
select * from t_user where name like '%'${name}'%'
(3)程序中拼接
String name = "%"+name+"%";
(4)大小写匹配查询
- SELECT * FROM TABLENAME WHERE UPPER(SUBSYSTEM) LIKE '%' || UPPER('jz') || '%'
- --或者是
- SELECT * FROM TABLENAME WHERE LOWER(SUBSYSTEM) LIKE '%' || LOWER('jz') || '%'
二、日期查询
<select id="showUser" parameterType="java.util.Map" resultType="User">select * from t_user where 1=1 <if test="uname!=null and unmae!='' " >and uname like '%${uname}%'</if><if test="searchCreateTimeStart !=null and searchCreateTimeStart !=''"><![CDATA[ and createTime >=#{searchCreateTimeStart} ]]></if><if test="searchCreateTimeEnd !=null and searchCreateTimeEnd !=''"><![CDATA[ and createTime <=#{searchCreateTimeEnd} ]]></if><if test="searchModifyTimeStart !=null and searchModifyTimeStart !=''"><![CDATA[ and ModifyTime >=#{searchModifyTimeStart} ]]></if><if test="searchModifyTimeEnd !=null and searchModifyTimeEnd !=''"><![CDATA[ and modifyTime <=#{searchModifyTimeEnd} ]]></if><if test="sort!=null and order!=null">order by ${sort} ${order}</if>limit #{start} , #{rows}</select>
模糊查询部分转载自( http://blog.csdn.net/luqin1988/article/details/7865643)
0 0
- mybatis 查询小结
- mybatis小结
- Mybatis小结
- mybatis小结
- MyBatis小结
- myBatis查询
- mybatis查询
- Mybatis查询
- mybatis 查询
- Mybatis--查询
- Mybatis查询
- mybatis 实现一对一,一对多,多对多关联查询 小结
- mybatis--foreach,choose 小结
- MyBatis的使用小结
- mybatis 使用经验小结
- Mybatis项目小结
- Mybatis 动态sql 小结
- mybatis学习小结
- 数组名和数组名取地址&
- mfc中嵌入ppt,播放的时候在对话框中播放
- Maven项目中用Memcached实现缓存配置
- 关于UIButton的titleEdgeInsets和imageEdgeInsets属性
- UIReferenceLibraryViewController iOS自带的词典controller
- mybatis 查询小结
- IE11 及 Chrome 中 控件位置显示问题
- JIRA
- reactJS之react-route
- 手动启动libreOffice服务
- 后台容器杂学
- 数据挖掘期刊、论坛、博客、数据集
- POS恶意软件,可回传信用卡号及个人资料
- 二叉搜索树的后序遍历序列-剑指offer(java实现)