MySql acos in between where clause
up vote
-1
down vote
favorite
I have this where clause:
where (6371 * acos(cos(radians(43)) * cos(radians(professional_latitude)) * cos(radians(professional_longitude) - radians
(-79)) + sin(radians(43)) * sin(radians(professional_latitude)))) BETWEEN 15 AND 40
and its returning no results, even though there is a record in my database that is 30KM from location, when I do this:
where (6371 * acos(cos(radians(43)) * cos(radians(professional_latitude)) * cos(radians(professional_longitude) - radians
(-79)) + sin(radians(43)) * sin(radians(professional_latitude)))) < 40
I get the expected results, why is my Between not working?
I have also tried:
where (6371 * acos(cos(radians(43)) * cos(radians(professional_latitude)) * cos(radians(professional_longitude) - radians
(-79)) + sin(radians(43)) * sin(radians(professional_latitude)))) > 15 AND (6371 * acos(cos(radians(43)) * cos(radians(professional_latitude)) * cos(radians(professional_longitude) - radians
(-79)) + sin(radians(43)) * sin(radians(professional_latitude)))) < 40
I get the same result as between, which is nothing.
mysql
add a comment |
up vote
-1
down vote
favorite
I have this where clause:
where (6371 * acos(cos(radians(43)) * cos(radians(professional_latitude)) * cos(radians(professional_longitude) - radians
(-79)) + sin(radians(43)) * sin(radians(professional_latitude)))) BETWEEN 15 AND 40
and its returning no results, even though there is a record in my database that is 30KM from location, when I do this:
where (6371 * acos(cos(radians(43)) * cos(radians(professional_latitude)) * cos(radians(professional_longitude) - radians
(-79)) + sin(radians(43)) * sin(radians(professional_latitude)))) < 40
I get the expected results, why is my Between not working?
I have also tried:
where (6371 * acos(cos(radians(43)) * cos(radians(professional_latitude)) * cos(radians(professional_longitude) - radians
(-79)) + sin(radians(43)) * sin(radians(professional_latitude)))) > 15 AND (6371 * acos(cos(radians(43)) * cos(radians(professional_latitude)) * cos(radians(professional_longitude) - radians
(-79)) + sin(radians(43)) * sin(radians(professional_latitude)))) < 40
I get the same result as between, which is nothing.
mysql
can you please tell what is returning result without usingBETWEEN
. That is, if your query stop beforeBETWEEN
then what is the result?
– Akhter Alamin Farhan
Nov 11 at 6:18
If I use < 40 instead of BETWEEN 15 AND 40 I get the expected results, if I remove the BETWEEN I would get and error on the Where condition, if I remove the WHERE clause all my records appear.
– user979331
Nov 11 at 6:26
BETWEEN 15 AND 40
should have worked. Check fiddle here sqlfiddle.com/#!9/79d5b6/2. Check your query again for any errors.
– Samir
Nov 11 at 7:48
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I have this where clause:
where (6371 * acos(cos(radians(43)) * cos(radians(professional_latitude)) * cos(radians(professional_longitude) - radians
(-79)) + sin(radians(43)) * sin(radians(professional_latitude)))) BETWEEN 15 AND 40
and its returning no results, even though there is a record in my database that is 30KM from location, when I do this:
where (6371 * acos(cos(radians(43)) * cos(radians(professional_latitude)) * cos(radians(professional_longitude) - radians
(-79)) + sin(radians(43)) * sin(radians(professional_latitude)))) < 40
I get the expected results, why is my Between not working?
I have also tried:
where (6371 * acos(cos(radians(43)) * cos(radians(professional_latitude)) * cos(radians(professional_longitude) - radians
(-79)) + sin(radians(43)) * sin(radians(professional_latitude)))) > 15 AND (6371 * acos(cos(radians(43)) * cos(radians(professional_latitude)) * cos(radians(professional_longitude) - radians
(-79)) + sin(radians(43)) * sin(radians(professional_latitude)))) < 40
I get the same result as between, which is nothing.
mysql
I have this where clause:
where (6371 * acos(cos(radians(43)) * cos(radians(professional_latitude)) * cos(radians(professional_longitude) - radians
(-79)) + sin(radians(43)) * sin(radians(professional_latitude)))) BETWEEN 15 AND 40
and its returning no results, even though there is a record in my database that is 30KM from location, when I do this:
where (6371 * acos(cos(radians(43)) * cos(radians(professional_latitude)) * cos(radians(professional_longitude) - radians
(-79)) + sin(radians(43)) * sin(radians(professional_latitude)))) < 40
I get the expected results, why is my Between not working?
I have also tried:
where (6371 * acos(cos(radians(43)) * cos(radians(professional_latitude)) * cos(radians(professional_longitude) - radians
(-79)) + sin(radians(43)) * sin(radians(professional_latitude)))) > 15 AND (6371 * acos(cos(radians(43)) * cos(radians(professional_latitude)) * cos(radians(professional_longitude) - radians
(-79)) + sin(radians(43)) * sin(radians(professional_latitude)))) < 40
I get the same result as between, which is nothing.
mysql
mysql
edited Nov 11 at 6:28
asked Nov 11 at 6:05
user979331
22129112215
22129112215
can you please tell what is returning result without usingBETWEEN
. That is, if your query stop beforeBETWEEN
then what is the result?
– Akhter Alamin Farhan
Nov 11 at 6:18
If I use < 40 instead of BETWEEN 15 AND 40 I get the expected results, if I remove the BETWEEN I would get and error on the Where condition, if I remove the WHERE clause all my records appear.
– user979331
Nov 11 at 6:26
BETWEEN 15 AND 40
should have worked. Check fiddle here sqlfiddle.com/#!9/79d5b6/2. Check your query again for any errors.
– Samir
Nov 11 at 7:48
add a comment |
can you please tell what is returning result without usingBETWEEN
. That is, if your query stop beforeBETWEEN
then what is the result?
– Akhter Alamin Farhan
Nov 11 at 6:18
If I use < 40 instead of BETWEEN 15 AND 40 I get the expected results, if I remove the BETWEEN I would get and error on the Where condition, if I remove the WHERE clause all my records appear.
– user979331
Nov 11 at 6:26
BETWEEN 15 AND 40
should have worked. Check fiddle here sqlfiddle.com/#!9/79d5b6/2. Check your query again for any errors.
– Samir
Nov 11 at 7:48
can you please tell what is returning result without using
BETWEEN
. That is, if your query stop before BETWEEN
then what is the result?– Akhter Alamin Farhan
Nov 11 at 6:18
can you please tell what is returning result without using
BETWEEN
. That is, if your query stop before BETWEEN
then what is the result?– Akhter Alamin Farhan
Nov 11 at 6:18
If I use < 40 instead of BETWEEN 15 AND 40 I get the expected results, if I remove the BETWEEN I would get and error on the Where condition, if I remove the WHERE clause all my records appear.
– user979331
Nov 11 at 6:26
If I use < 40 instead of BETWEEN 15 AND 40 I get the expected results, if I remove the BETWEEN I would get and error on the Where condition, if I remove the WHERE clause all my records appear.
– user979331
Nov 11 at 6:26
BETWEEN 15 AND 40
should have worked. Check fiddle here sqlfiddle.com/#!9/79d5b6/2. Check your query again for any errors.– Samir
Nov 11 at 7:48
BETWEEN 15 AND 40
should have worked. Check fiddle here sqlfiddle.com/#!9/79d5b6/2. Check your query again for any errors.– Samir
Nov 11 at 7:48
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246279%2fmysql-acos-in-between-where-clause%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
can you please tell what is returning result without using
BETWEEN
. That is, if your query stop beforeBETWEEN
then what is the result?– Akhter Alamin Farhan
Nov 11 at 6:18
If I use < 40 instead of BETWEEN 15 AND 40 I get the expected results, if I remove the BETWEEN I would get and error on the Where condition, if I remove the WHERE clause all my records appear.
– user979331
Nov 11 at 6:26
BETWEEN 15 AND 40
should have worked. Check fiddle here sqlfiddle.com/#!9/79d5b6/2. Check your query again for any errors.– Samir
Nov 11 at 7:48