gpt4 book ai didi

mysql - 使用第一个 sql 语句结果到另一个 sql 语句

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

基本上我想做的是从 roadData 中选择所有坐标一个一个然后找到tweetMelbourne中20以内的所有点英里并将这些点插入到另一个表中。

因此,对于 roadData 表中的每个 (x,y),从中找到相邻的数据点tweetMelbourne 并将这些点插入到另一个新表中。

所以我必须这样做:

SELECT geo_coordinates_latitude, geo_coordinates_longitude
FROM tweetmelbourne
HAVING ( 3959 * acos( cos( radians(latitude) ) * cos( radians( geo_coordinates_latitude ) ) *
cos( radians( geo_coordinates_longitude ) - radians(longitude) ) + sin( radians(latitude) ) *
sin( radians( geo_coordinates_latitude ) ) ) ) < .1 ORDER BY distance LIMIT 0 , 20;

我必须从另一个表中获取其中的纬度和经度值:

select longitude,latitude from roadData;

描述tweetmelbourne;

enter image description here

描述道路数据;

enter image description here

SELECT geo_coordinates_latitude, geo_coordinates_longitude
FROM tweetmelbourne;

enter image description here

select longitude,latitude from roadData;

enter image description here

最佳答案

具有多个参数的 IN() 的正确语法是:(Val1,Val2) IN(SELECT VAL1,val2..

SELECT t.address,(t.x+t.y) as z 
FROM student t
WHERE (t.x,t.y) IN(SELECT x,y FROM tweet)

也可以通过连接来完成:

SELECT t.address,(t.x+t.y) as z 
FROM student t
JOIN tweet s
ON(t.x = s.x and t.y = s.y)

编辑:我想你想要的是:

SELECT s.address,t.x+t.y as z
FROM student s
CROSS JOIN tweet t

关于mysql - 使用第一个 sql 语句结果到另一个 sql 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39943446/

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