冈斯特 2020-09-26 17:12 采纳率: 100%
浏览 262
已采纳

navicat中可以运行的inner join 在mybatis中运行语法错误

navicat 中的语句

                SELECT
            blog.*,users.nickname,users.id AS uid,m.blogs_id,m.tags_id AS tid,t.`name` AS tname
        FROM
            ((t_blog  blog,
            t_type types,
            t_user users)
            INNER JOIN t_blog_tags  m ON blog.id=m.blogs_id)
            INNER JOIN t_tag  t ON t.id=m.tags_id
        WHERE
             blog.type_id = types.id
            AND users.id = blog.user_id
        ORDER BY
            blog.updateTime DESC

图片说明

在mybatis中报语法错
图片说明

JDBC Connection [HikariProxyConnection@473404166 wrapping com.mysql.cj.jdbc.ConnectionImpl@727b8f8c] will not be managed by Spring
==> Preparing: SELECT count(0) FROM ((t_blog blog t_type types t_user users) INNER JOIN t_blog_tags m ON blog.id = m.blogs_id) INNER JOIN t_tag t ON t.id = m.tags_id WHERE blog.type_id = types.id AND users.id = blog.user_id
==> Parameters:
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@180804df]
2020-09-26 17:09:13.944 ERROR 4748 --- [-nio-80-exec-10] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException:

Error querying database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't_type types t_user users) INNER JOIN t_blog_tags m ON blog.id = m.blogs_id) INN' at line 1

The error may exist in file [F:\java\blog\target\classes\mybatis\mapper\BlogMapper.xml]

The error may involve defaultParameterMap

The error occurred while setting parameters

SQL: SELECT count(0) FROM ((t_blog blog t_type types t_user users) INNER JOIN t_blog_tags m ON blog.id = m.blogs_id) INNER JOIN t_tag t ON t.id = m.tags_id WHERE blog.type_id = types.id AND users.id = blog.user_id

Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't_type types t_user users) INNER JOIN t_blog_tags m ON blog.id = m.blogs_id) INN' at line 1

; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't_type types t_user users) INNER JOIN t_blog_tags m ON blog.id = m.blogs_id) INN' at line 1] with root cause

java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't_type types t_user users) INNER JOIN t_blog_tags m ON blog.id = m.blogs_id) INN' at line 1

  • 写回答

1条回答 默认 最新

  • Keifei 2020-09-27 11:38
    关注

    很有可能是制表符的问题,你把制表符换成空格试一下。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)