繁体   English   中英

存储过程:MySQL,错误

[英]Stored Procedure: MySQL, Error

无法选择ID字段INTO @testId表,其显示错误代码。

使用代码

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;

尝试这个...

  // 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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM