Mark Goodge wrote:
This is the sort of thing that is far better handled in the
application layer, rather than the database layer. PHP, for example,
even has a built-in function which will do this:
setype($value,float);
I agree about using the application layer, but I like to use type
On 7/20/2010 10:07 AM, Chris W wrote:
I try to avoid asking why but in this case I have to. I can't imagine
wanting to have a list of numbers displayed and not have them all
aligned right with the sane number of digits after the decimal
point. So why would you even want to do this is?
FLOOR() CEIL() or ROUND()
SELECT ROUND(1+1.6, 0);
= 3
SELECT FLOOR(1+1.6);
= 2
SELECT CEIL(1+1.6);
= 3
Steven Staples
-Original Message-
From: Ashley M. Kirchner [mailto:ash...@pcraft.com]
Sent: July 20, 2010 1:52 PM
To: mysql@lists.mysql.com
Subject: Re: [MySQL] Re: Decimal points
mysql select 1+1.0;
+---+
| 1+1.0 |
+---+
| 2.0 |
+---+
1 row in set (0.00 sec)
mysql select 1+1.1;
+---+
| 1+1.1 |
+---+
| 2.1 |
+---+
1 row in set (0.00 sec)
Is there a way to tell MySql to only return '2' in the first select as
opposed to
On 19/07/2010 10:04, Ashley M. Kirchner wrote:
Is there a way to tell MySql to only return '2' in the first select as
opposed to '2.0'? The second select is correct and should remain as such.
Not easily, no.
Basically I have two columns, one with an integer and another with a
...@pcraft.com]
Sent: Monday, July 19, 2010 2:35 PM
To: mysql@lists.mysql.com
Subject: Decimal points
mysql select 1+1.0;
+---+
| 1+1.0 |
+---+
| 2.0 |
+---+
1 row in set (0.00 sec)
mysql select 1+1.1;
+---+
| 1+1.1 |
+---+
| 2.1 |
+---+
1 row in set (0.00
Hi,
Let try '' to treat numeric as character
For example:
select 1+'1.0';
== 2
select 1+'1.1';
== 2.1
- Original Message -
From: Mark Goodge m...@good-stuff.co.uk
To: mysql@lists.mysql.com
Sent: Monday, July 19, 2010 4:31:51 PM
Subject: Re: Decimal points
On 19/07/2010 10:04