首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >存储过程: MySQL,错误

问存储过程: MySQL,错误
EN

Stack Overflow用户
提问于 2018-03-30 05:12:34
回答 1查看 30关注 0票数 0

无法在@testId表中选择id字段,其显示错误代码。

使用的代码

代码语言:javascript
复制
SELECT id INTO @testId, (3959 * ACOS (COS ( RADIANS(deviceLat ) ) * COS( RADIANS(`latitude`) )* 
COS( RADIANS(`longitude` ) - RADIANS(deviceLong) )+ SIN ( RADIANS(deviceLat) )* 
SIN( RADIANS(`latitude` )))) AS dist INTO @distance FROM route_waypoints 
GROUP BY route_ID = @routeID AND (route_waypoints.type =  'PICK' OR 
route_waypoints.type = 'CAMPUS') HAVING dist < 250  ORDER BY dist ASC LIMIT 1;
EN

回答 1

Stack Overflow用户

发布于 2018-03-30 05:16:48

试试这个..。

代码语言:javascript
复制
  // Declare variables with datatype and size
    DECLARE @testId int, @distance varchar(500 

    // set value of the selected column to that variable by = operator.
    SELECT @testId = id, 
           @distance = (3959 * ACOS (COS ( RADIANS(deviceLat ) ) * COS( RADIANS(`latitude`) )* 
                        COS( RADIANS(`longitude` ) - RADIANS(deviceLong) )+ SIN ( RADIANS(deviceLat) )* 
                        SIN( RADIANS(`latitude` ))))
            FROM route_waypoints 
            GROUP BY route_ID = @routeID AND (route_waypoints.type =  'PICK' 
            OR route_waypoints.type = 'CAMPUS') HAVING dist < 250  
            ORDER BY dist ASC LIMIT 1;    

   // Print    
   SELECT @testId, @distance
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49568722

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档