sql语句问题

qq_36341622 2017-06-06 04:54:41
...全文
125 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
PrettyTutu 2017-06-06
  • 打赏
  • 举报
回复
select count(menu_id) num from menu where menu_del=0 <when test='menuName!=""&&menuName!=null'> and menu_name like '%${menuName}%' </when> <when test='menuFather!=""&&menuFather!=null'> and menu_father=#{menuFather} </when>
xwn_2016 2017-06-06
  • 打赏
  • 举报
回复
<where>
			<if test="userPhone != null and userPhone != ''">
				AND wu.user_phone LIKE CONCAT(#{userPhone}, '%')
			</if>
			<if test="userName != null and userName != ''">
				AND wu.user_account LIKE CONCAT(#{userName}, '%')
			</if>
			<if test="provinceId != null and provinceId != ''">
				AND uoi.province_id = ${provinceId}
			</if>
			<if test="cityId != null and cityId != ''">
				AND uoi.city_id = ${cityId}
			</if>
			<if test="companyInfo != null and companyInfo != ''">
				AND uoi.company_info = '${companyInfo}'
			</if>
		</where>
用CONCAT函数
podd 2017-06-06
  • 打赏
  • 举报
回复
当条件不成立时就会变成 select * from tab where 这样写条件 <where> <if test=""> <if> </where>
自由自在_Yu 2017-06-06
  • 打赏
  • 举报
回复
去掉中间两个单引号试试

51,410

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧