RE: CAST
| From: | Mark Kirkwood | Date: | Thu, 28 Sep 2000 22:35:52 +0000 |
| Subject: | RE: CAST | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-3156@lists.php.net to get a copy of this message | ||
I am assuming that the db is Postgresql ....
Postgresql appears to cast "bare" numbers as float8 ( at least in 7.1 dev version I am
running it does ...)
so change your query to
SELECT * FROM tavola_pesi WHERE ((da_kg < 3.5::numeric) and (a_kg >= 3.5::numeric))
or
SELECT * FROM tavola_pesi WHERE ((da_kg < cast( 3.5 as numeric) and (a_kg >= cast(3.5 as
numeric)))
which is probably better
Cheers
Mark
> -----Original Message-----
> From: Enrico Comini [SMTP:algobit@algobit.com]
> Sent: Thursday, September 28, 2000 8:57 PM
> To: ML-PHP-DB
> Subject: CAST
>
> Hi, how I have to change the next query ?
>
> da_kg=Numeric
> a_kg =Numeric
>
> cusiodb=# SELECT * FROM tavola_pesi WHERE ((da_kg < 3.5) and (a_kg >= 3.5));
> ERROR: Unable to identify an operator '<' for types 'numeric' and
> 'float8'
> You will have to retype this query using an explicit cast