Re: Round a number
| From: | Ignatius Reilly | Date: | Fri, 03 Oct 2003 15:49:24 +0000 |
| Subject: | Re: Round a number | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-30826@lists.php.net to get a copy of this message | ||
I just realized that this does not work with integers such as 80,
so one should add a test condition:
SELECT
IF(
ROUND( mycol ) = mycol,
mycol,
TRIM( TRAILING
'.'
FROM TRIM( TRAILING '0' FROM mycol )
)
)
Ignatius
_________________________
----- Original Message -----
From: "Ignatius Reilly" <ignatius.reilly@free.fr>
To: "DB list PHP" <php-db@lists.php.net>; "Shaun"
<shaun@mania.plus.com>
Sent: Friday, October 03, 2003 5:27 PM
Subject: Re: [PHP-DB] Round a number
> SELECT
> TRIM( TRAILING
> '.'
> FROM TRIM( TRAILING '0' FROM mycol )
> )
>
>
> Ignatius
> _________________________
> ----- Original Message -----
> From: "Shaun" <shaun@mania.plus.com>
> To: <php-db@lists.php.net>
> Sent: Friday, October 03, 2003 5:12 PM
> Subject: [PHP-DB] Round a number
>
>
> > Hi,
> >
> > I have a query that returns a number from culculation in my table. It
> > returns say 4.00, 8.75, 0.00, 12.50 etc. How can I get MySQL to return
the
> > number without any zeros, i.e. 4, 8.75, 0, 12.5 etc?
> >
> > Thanks for your help
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>