navicat中可以运行的inner join 在mybatis中运行语法错误
navicat 中的语句
SELECTblog.*,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 [[email protected] wrapping [email protected]] 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 [[email protected]]
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
回答
很有可能是制表符的问题,你把制表符换成空格试一下。
以上是 navicat中可以运行的inner join 在mybatis中运行语法错误 的全部内容, 来源链接: utcz.com/a/47384.html