Jump to content

Keeping .00 On Data.


shadowayex
 Share

Recommended Posts

I have a field set to the data type FLOAT so I can have decimals in it. When I put something with .00 on the end (6.00, for example), it automatically cuts off the .00. I understand why it does this, but I was wondering if there's a way to make it not do that.

Link to comment
Share on other sites

try only selecting the one field from the table

mysql_query("SELECT FORMAT(balance, 2) FROM accounts ORDER BY name ASC");

Notice that the '*' selector is missing?You might need to specify the particular field you want selected.

Edited by jlhaslip
Link to comment
Share on other sites

I tried it and the query fails:mysql_query("SELECT FORMAT(balance, 2) * FROM accounts ORDER BY name ASC");The query works without the FORMAT(balance, 2).
You have to put commas between the columns that you want returned. This query:
SELECT FORMAT(balance, 2) * FROM accounts ORDER BY name ASC

is going to fail just like this would:

SELECT balance name FROM accounts ORDER BY name ASC

Try this:

SELECT FORMAT(balance, 2), * FROM accounts ORDER BY name ASC

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...