Problem with retrieving records using double precision fields - Mailing list pgsql-general

From Raymond C. Rodgers
Subject Problem with retrieving records using double precision fields
Date
Msg-id 497759C6.6020205@gmail.com
Whole thread Raw
Responses Re: Problem with retrieving records using double precision fields
Re: Problem with retrieving records using double precision fields
List pgsql-general
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

pgsql-general by date:

Previous
From: "Albe Laurenz"
Date:
Subject: Re: How to find how much postgresql use the memory?
Next
From: Sam Mason
Date:
Subject: Re: Problem with retrieving records using double precision fields