Jump to content

Very SIMPLE MySql Problem...


rckehoe

Recommended Posts

I am going to loose my mind, I am running into an issue that has got me stumped... This is suppose to be a very easy thing to do, but for some reason cannot figure it out... Any help is appreciated.

 

I have got small table in my database called "vendors"... Inside this table I only have about 2-3 records... Each of these records contains a latitude and longitude. Fields are called "lat" and "lon"

 

I have a VERY simple mysql query like this:

SELECT * FROM `vendors` WHERE (`lon` BETWEEN "-76.3066" AND "-133.5176")

 

I have one specific record in the database that has a 'lon' of -104.884082.... In theory it should be pulling this record, but for some reason NO results are generated....

 

Have I gone off the deep end or something? I have tried everything I can possibly thing of with no luck!!!

 

Someone please help me!

 

 

Link to comment
https://forums.phpfreaks.com/topic/192874-very-simple-mysql-problem/
Share on other sites

I think no results are returned cuz -76 > -133 when between operation wants get boundries

 

likse so (`lon` BETWEEN min AND max)

 

here's how the query should look:

SELECT * FROM `vendors` WHERE (`lon` BETWEEN  -133.5176 AND -76.3066 )

 

In php to avoid such problem build your query with min() max() functions

 

$a = -133.5176;
$b = -76.3066;
$query = "SELECT * FROM `vendors` WHERE (`lon` BETWEEN  ".min($a, $b)." AND ".max($a, $b)." )";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.