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
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)." )";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.