mysql里面 ibatis的like模糊查询问题, 谢谢,请问我的sql语句是否有错,问题是 查询条件可输入可不输入
<!--根据用户名搜索用户--><selectid="selectUserByUsername"parameterClass="Users"resultMap="resu...
<!-- 根据用户名搜索用户 -->
<select id="selectUserByUsername" parameterClass="Users" resultMap="resultUsers">
SELECT
a.USER_ID,
a.LOGIN_NAME,
a.SHOW_NAME,
a.PASS_WORD,
a.CREATE_TIME,
a.GROUP_ID,
a.ADMIN_FLG
FROM
table_user AS a
<dynamic prepend="WHERE">
<isNotEmpty property="loginName">
a.LOGIN_NAME LIKE '%$loginName$%'
</isNotEmpty>
<isNotEmpty prepend="AND" property="showName">
a.SHOW_NAME LIKE '%$showName$%'
</isNotEmpty>
<isNotEmpty prepend="AND" property="adminFlag">
a.GROUP_ID = #groupId#
</isNotEmpty>
<isNotEmpty prepend="AND" property="adminFlag">
a.ADMIN_FLG = #adminFlag#
</isNotEmpty>
</dynamic>
ORDER BY
a.USER_ID DESC
</select>
请问我的语句是否有错 展开
<select id="selectUserByUsername" parameterClass="Users" resultMap="resultUsers">
SELECT
a.USER_ID,
a.LOGIN_NAME,
a.SHOW_NAME,
a.PASS_WORD,
a.CREATE_TIME,
a.GROUP_ID,
a.ADMIN_FLG
FROM
table_user AS a
<dynamic prepend="WHERE">
<isNotEmpty property="loginName">
a.LOGIN_NAME LIKE '%$loginName$%'
</isNotEmpty>
<isNotEmpty prepend="AND" property="showName">
a.SHOW_NAME LIKE '%$showName$%'
</isNotEmpty>
<isNotEmpty prepend="AND" property="adminFlag">
a.GROUP_ID = #groupId#
</isNotEmpty>
<isNotEmpty prepend="AND" property="adminFlag">
a.ADMIN_FLG = #adminFlag#
</isNotEmpty>
</dynamic>
ORDER BY
a.USER_ID DESC
</select>
请问我的语句是否有错 展开
3个回答
展开全部
<dynamic prepend="WHERE">
<isNotEmpty property="loginName">
a.LOGIN_NAME LIKE '%$loginName$%' AND
</isNotEmpty>
<isNotEmpty property="showName">
a.SHOW_NAME LIKE '%$showName$%' AND
</isNotEmpty>
<isNotEmpty property="adminFlag">
a.GROUP_ID = #groupId# AND
</isNotEmpty>
<isNotEmpty property="adminFlag">
a.ADMIN_FLG = #adminFlag#
</isNotEmpty>
</dynamic>
<isNotEmpty property="loginName">
a.LOGIN_NAME LIKE '%$loginName$%' AND
</isNotEmpty>
<isNotEmpty property="showName">
a.SHOW_NAME LIKE '%$showName$%' AND
</isNotEmpty>
<isNotEmpty property="adminFlag">
a.GROUP_ID = #groupId# AND
</isNotEmpty>
<isNotEmpty property="adminFlag">
a.ADMIN_FLG = #adminFlag#
</isNotEmpty>
</dynamic>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
where 1=1
然后在第一个模糊查询中也加"AND"
然后在第一个模糊查询中也加"AND"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询