shadowayex Posted September 21, 2009 Share Posted September 21, 2009 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 More sharing options...
jlhaslip Posted September 21, 2009 Share Posted September 21, 2009 http://www.plus2net.com/sql_tutorial/format.php Link to comment Share on other sites More sharing options...
shadowayex Posted September 21, 2009 Author Share Posted September 21, 2009 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). Link to comment Share on other sites More sharing options...
jlhaslip Posted September 21, 2009 Share Posted September 21, 2009 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. Link to comment Share on other sites More sharing options...
jesh Posted September 24, 2009 Share Posted September 24, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.