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
> decimal. And I'm adding the two, but for those where the decimal has a .0,
> I just want the result to not have the .0 and for those that do have
> anything other than .0, to display it accordingly.
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:
$val = "2.1";
$val = "2.0";
Even if other languages don't have built-in functions to do this, it's a
trivial piece of code to recreate it.