Author Topic: Very SIMPLE MySql Problem...  (Read 312 times)

0 Members and 1 Guest are viewing this topic.

Offline rckehoeTopic starter

  • Irregular
  • Posts: 33
    • View Profile
Very SIMPLE MySql Problem...
« on: February 21, 2010, 07:49:50 PM »
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!


Offline sader

  • Enthusiast
  • Posts: 268
    • View Profile
Re: Very SIMPLE MySql Problem...
« Reply #1 on: February 22, 2010, 08:02:02 AM »
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)." )";
« Last Edit: February 22, 2010, 08:02:38 AM by sader »

Offline rckehoeTopic starter

  • Irregular
  • Posts: 33
    • View Profile
Re: Very SIMPLE MySql Problem...
« Reply #2 on: February 22, 2010, 05:05:29 PM »
Well sock me sideways, it actually worked!!!
I cannot tell you how much you have helped me out! THANK YOU SO MUCH!