Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Multiple between statement not returning

Author  Topic 

wales321
Starting Member

27 Posts

Posted - 2013-08-11 : 14:38:15
I have an SQL statement to find attractions between certain longitude and latitude values. The attraction i have already added to the database to test has values 51.502899 and 0.003552 for latitude and longitude. As you can see these values fall within the limits of the statement below but nothing is returned.

SELECT * FROM Attractions WHERE (Lat BETWEEN 51.51998 AND 51.49999) AND  (Long BETWEEN 0.014 AND -0.006);

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2013-08-11 : 15:01:01
The values in BETWEEN statement must always be in ascending order.
SELECT * FROM Attractions WHERE (Lat BETWEEN 51.49999 AND 51.51998) AND (Long BETWEEN -0.006 AND 0.014);



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

wales321
Starting Member

27 Posts

Posted - 2013-08-11 : 15:13:17
Excellent! Simple fix and it is working now, thank you.
Go to Top of Page
   

- Advertisement -