gpt4 book ai didi

mysql - mysql内部连接出现sql错误

转载 作者:行者123 更新时间:2023-11-29 23:12:03 24 4
gpt4 key购买 nike

String sql = "set @row \\:=-1; SELECT ue.id, ue.Latitude, ue.Longitude, ue.Serving_Cell, ue.RSCP 
FROM ue INNER JOIN(
SELECT id
from (
SELECT @row \\:=@row+1 as rownum, id
from (
select id from ue order by id) as sorted
)as ranked
where rownum %20=0) as subset
on subset.id = ue.id
where Operator like :operator ";

Query query = getSessionFactory().getCurrentSession().createSQLQuery(sql);

query.setParameter("operator", "%" + operator + "%");

return query.list();

请帮我找到我的sql错误控制台渲染我:严重:路径 [/SpringSecurity] 上下文中 servlet [mvc-dispatcher] 的 Servlet.service() 抛出异常 [请求处理失败;嵌套异常是 org.hibernate.exception.SQLGrammarException: 无法提取 ResultSet] 其根本原因com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的 SQL 语法有错误; 检查与您的 MySQL 服务器版本相对应的手册,了解在“SELECT ue.id, ue.Latitude, ue.Longitude, ue.Serving_Cell, ue.RSCP FROM ue INNER ”附近使用的正确语法第 1 行

最佳答案

您尝试同时执行 2 个查询。您一次只能执行一个。

SELECT ue.id, ue.Latitude, ue.Longitude, ue.Serving_Cell, ue.RSCP 
FROM ue INNER JOIN(
SELECT id
from (
SELECT @row \\:=@row+1 as rownum, id
from (
select id, @row
from ue, (select @row := -1) r
order by id) as sorted
)as ranked
where rownum %20=0) as subset
on subset.id = ue.id
where Operator like :operator

但是您可以使用子查询来初始化这样的变量

(select @row := -1) r

关于mysql - mysql内部连接出现sql错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28026725/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com