In two separate databases that are configured to have latitude and longitude as double precision fields, I'm having trouble retrieving records using "between" on the longitude field. I know that I have data within range, but any query involving the longitude field fails to find records.

Here's a quick example table; it's not the actual table in either database, but it's close enough to demonstrate my point on PostgreSQL 8.3.5 on Fedora 10 x86_64:

test=# create table coordtest (id serial, latitude float, longitude float);
NOTICE: CREATE TABLE will create implicit sequence "coordtest_id_seq" for serial column "coordtest.id"
CREATE TABLE
test=# insert into coordtest(latitude,longitude) values (42.38013,-83.05175),(42.411143,-82.943461);
INSERT 0 2
test=# select * from coordtest where latitude between 42.0 and 42.5 and longitude between -83.0 and -84.0;
id | latitude | longitude
----+----------+-----------
(0 rows)



test=# select * from coordtest;
id | latitude | longitude ----+-----------+------------
 1 |  42.38013 |  -83.05175
 2 | 42.411143 | -82.943461
(2 rows)

test=# select * from coordtest where latitude between 42.0 and 42.5 ;
id | latitude | longitude ----+-----------+------------
 1 |  42.38013 |  -83.05175
 2 | 42.411143 | -82.943461
(2 rows)

test=# select * from coordtest where longitude between -83.0 and -84.0;
id | latitude | longitude
----+----------+-----------
(0 rows)


Any idea what's going on here and why I'm not getting results?
Thanks,
Raymond

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to