gpt4 book ai didi

java - java中嵌套sql查询错误

转载 作者:行者123 更新时间:2023-11-29 07:36:00 24 4
gpt4 key购买 nike

Statement stmt = conn.createStatement();

sql = "SELECT P1, P2 FROM " + "(SELECT (3959 * acos(cos(radians(T2.origin_lat)) * cos(radians( T1.origin_lat )) * cos(radians(T1.origin_lon) - radians(T2.origin_lon)) + sin(radians(T2.origin_lat)) * sin(radians(T1.origin_lat )))) " + "as dis," + "T1.id as P1,T2.id as P2 FROM public.dummy T1 CROSS JOIN public.dummy T2 " + "where P1 != P2 ) res" + "where res.dis<=.05 order by P1";

ResultSet rs = stmt.executeQuery(sql);

出现此错误

org.postgresql.util.PSQLException: ERROR: syntax error at or near "res" Position: 326

PS - 相同的查询正在 MySQL 中运行。这种 View 创建在java中不起作用吗?我应该做出什么改变?谢谢

最佳答案

P2) res"+ "其中

我不是专家,但是放置空间怎么样? :)

关于java - java中嵌套sql查询错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30811247/

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