From: | Alban Hertroys <alban(at)magproductions(dot)nl> |
---|---|
To: | Crystle Numan <crys(at)guidedvision(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Select gives the wrong results |
Date: | 2005-08-30 11:01:20 |
Message-ID: | 43143C80.7060306@magproductions.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Crystle Numan wrote:
> Dear all:
>
> I am fairly knowledgeable about PostgreSQL but this behaviour is
> stumping me. Any help would be wonderful. If you think it is a bug, let
> me now and I'll file one.
>
> (select values in DB (date stamps) between Jan 1, 2000 and Jan 1, 2005,
> no results)
>
> db_name=# SELECT * from person_detail WHERE field='2' AND
> value>'946702800' AND value<'1104555600';
> id | person | field | value
> ----+--------+-------+-------
> (0 rows)
You are comparing strings, which is not quite the same as a numerical
comparison. The above range is empty, as '9...' > '1...' (even though
the left string is shorter).
Either compare numbers, or left pad your left string with zeroes until
it's the same length as the right string.
--
Alban Hertroys
alban(at)magproductions(dot)nl
magproductions b.v.
T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede
//Showing your Vision to the World//
From | Date | Subject | |
---|---|---|---|
Next Message | Clodoaldo Pinto | 2005-08-30 11:13:15 | Re: update functions locking tables |
Previous Message | Martijn van Oosterhout | 2005-08-30 09:50:55 | Re: psql from Linux script |