[英]MySQL | Count rows IF 0 then return
I want to create a function which check if there a any locations within a certain distance from a waypoint.我想创建一个 function 来检查距离航路点一定距离内是否有任何位置。 the function to calculate the distance is already working.
计算距离的 function 已经开始工作了。 I start with the query shown below.
我从下面显示的查询开始。
select loc_id from wp where calc_distance(52.15819, 6.40726, wp.lat, wp.lon) <100;
This query wil result in several rows, the next step would be to count the amount of rows, why won't the query below result in a number?这个查询会产生几行,下一步是计算行数,为什么下面的查询不会产生一个数字?
select count(loc_id from wp where calc_distance(52.15819, 6.40726, wp.lat, wp.lon) <100);
Any thoughts?有什么想法吗?
Small side question: What wuold be perferred:小问题:推荐什么:
TIA TIA
ABBOV ABBOV
Syntax error is all.语法错误就是一切。 You need a closing parenthesis after
loc_id
在
loc_id
之后需要一个右括号
select count(loc_id) from wp where calc_distance(52.15819, 6.40726, wp.lat, wp.lon) <100;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.