我指定了表名还是提示 列名 'NAME' 不明确。求大神解答

txws198737 2015-08-13 04:53:10
以下是SQL代码:
<![CDATA[
select * from (select row_.*, ROW_NUMBER()over(order by row_.id desc) rownum_ from (
]]>
select TOP 100 PERCENT siteUser.ID,siteUser.NAME,siteUser.GENDER,siteUser.BIRTHDAY,siteUser.POLITICAL,siteUser.NATION,siteUser.TITLE,siteUser.PDA,siteUser.RADIO,siteUser.OTHER,siteUser.PHONE,siteUser.PHOTO,siteUser.SITEID,site.NAME SITE_NAME
from SYS_SITE_USER siteUser left join SYS_SITE site
on siteUser.SITEID = site.ID
<where>
<include refid = "other-condition"/>
</where>
order by id
<![CDATA[
)row_ )t where t.rownum_ between #{startrow} and #{endrow}
]]>




<sql id="other-condition">
<if test="name != null"> and NAME like #{name,javaType=String}</if>
<if test="gender != null"> and GENDER = #{gender,javaType=String}</if>
<if test="birthday != null"> and BIRTHDAY = #{birthday,javaType=Date}</if>
<if test="political != null"> and POLITICAL = #{political,javaType=String}</if>
<if test="nation != null"> and NATION = #{nation,javaType=String}</if>
<if test="title != null"> and TITLE = #{title,javaType=VARCHAR}</if>
<if test="pda != null"> and PDA = #{pda,javaType=String}</if>
<if test="radio != null"> and RADIO = #{radio,javaType=String}</if>
<if test="other != null"> and OTHER = #{other,javaType=String}</if>
<if test="phone != null"> and PHONE = #{phone,javaType=String}</if>
<if test="photo != null"> and PHOTO = #{photo,javaType=String}</if>
<if test="siteId != null"> and SITEID = #{siteId,javaType=Integer}</if>

<if test="siteName != null"> and SITE_NAME = #{siteName,javaType=String}</if>
</sql>
...全文
265 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
txws198737 2015-08-13
  • 打赏
  • 举报
回复
引用 3 楼 rui888 的回复:
错误报还是找不到,你把sql 放到 sql 环境中测试看看。到底那里的问题。
找出问题了,因为搜索后会涉及到2个sql,分别单独使用都没问题,但是因为有一个sql使用了关联查询,所以一起使用就出问题了。
tony4geek 2015-08-13
  • 打赏
  • 举报
回复
错误报还是找不到,你把sql 放到 sql 环境中测试看看。到底那里的问题。
txws198737 2015-08-13
  • 打赏
  • 举报
回复
引用 1 楼 rui888 的回复:
<if test="name != null"> and NAME like #{name,javaType=String}</if> 这个 指定下看看。 and xxxxxxx. NAME like #{name,javaType=String}
你好,我开始也觉得这里有问题,但是修改后他提示: ### Error querying database. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: 无法绑定由多个部分组成的标识符 "siteUser.NAME"。
tony4geek 2015-08-13
  • 打赏
  • 举报
回复
<if test="name != null"> and NAME like #{name,javaType=String}</if> 这个 指定下看看。 and xxxxxxx. NAME like #{name,javaType=String}

50,549

社区成员

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

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