qq_43010024
2020-12-26 16:52
采纳率: 100%
浏览 259
已采纳

mybatis-plus sql报错 Navicat正常执行

救救孩子吧

报错具体如下

### Error querying database.  Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: Method queryTotal execution error of sql : 
 SELECT COUNT(1) FROM ( SELECT twl.id,c.id as 'cid',c.mac_addr,c.`name`,c.remarks,twl.date,twl.state,twl.`port`
        FROM `t_log_wireless` twl
         WHERE  c.`name`=? 
        INNER JOIN `t_client` c ON twl.cid=c.id
        ORDER BY twl.id DESC,twl.date DESC ) TOTAL 

### The error may exist in file [E:\Workspace\IdeaProjects\wrdm\target\classes\mapper\LogWirelessDao.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: Method queryTotal execution error of sql : 
 SELECT COUNT(1) FROM ( SELECT twl.id,c.id as 'cid',c.mac_addr,c.`name`,c.remarks,twl.date,twl.state,twl.`port`
        FROM `t_log_wireless` twl
         WHERE  c.`name`=? 
        INNER JOIN `t_client` c ON twl.cid=c.id
        ORDER BY twl.id DESC,twl.date DESC ) TOTAL 
] with root cause

mapper xml

<select id="listFull" resultType="net.zzj6.wrdm.vo.LogWireless">
	SELECT twl.id,c.id as 'cid',c.mac_addr,c.`name`,c.remarks,twl.date,twl.state,twl.`port`
	FROM `t_log_wireless` twl
	<where>
		<if test="cname != null and cname != ''">
			and c.`name`=#{cname}
		</if>
	</where>
	INNER JOIN `t_client` c ON twl.cid=c.id
	ORDER BY twl.id DESC,twl.date DESC
</select>

用的mysql数据库  ER图如下

 

 Navicat正常执行的

 

 

求解答 谢谢。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • MrBUS 2020-12-26 21:10
    已采纳


    where条件卸载INNER JOIN后面谢谢,

     


    <select id="listFull" resultType="net.zzj6.wrdm.vo.LogWireless">

     

    SELECT twl.id,c.id as 'cid',c.mac_addr,c.`name`,c.remarks,twl.date,twl.state,twl.`port`

     

    FROM `t_log_wireless` twl

     

    INNER JOIN `t_client` c ON twl.cid=c.id

    <where>

     

    <if test="cname != null and cname != ''">

     

    and c.`name`=#{cname}

     

    </if>

     

    </where>

    ORDER BY twl.id DESC,twl.date DESC

     

    </select>

    点赞 打赏 评论
  • qq_43010024 2021-01-07 14:16

    谢谢  我后来发现了,粘过去的时候改错位置了

    点赞 打赏 评论

相关推荐 更多相似问题