Jump to content
Sign in to follow this  
shadowayex

Keeping .00 On Data.

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.

Share this post


Link to post
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).

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...