Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"shaving" zeros off the end 2

Status
Not open for further replies.

compudude86

IS-IT--Management
Jun 1, 2006
46
i want to remove the trailing numbers from my columns, lets say my price, for example, is 199.00, i get 199.0000. i was told to use the "ROUND(price,2)" but how would i apply that to the 5 or so columns? what would be my syntax?
 
are you removing them entirely or just for display purposes and keeping the records as is?

If permanently then you use an UPDATE along with the ROUND.

If for display purposes then you use that ROUND for each column name (replacing price as the column name).
 
ok, but what syntax would i use? i tried selecting a column in the query browser, then executing ROUND (XXXXX, 2) and it said i had a problem in the syntax
 
You can set the datatypes for the columns to DECIMAL so that the data is initially stored with the required precision and number of decimal places. See the manual:

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
ok, i figured out i could set it in mysql administrator. i just needed to change it form DECIMAL(19,4) to DECIMAL(19,2). now i know i should start another thread, but i dont want to fill up the forum with my questions, real quick, how do i set my fields to have the $ in it?
 
you wouldn't put the $ in your fields. you are storing numeric information not string information. To display the $ with your fields then you would use the CONCAT operator like this.

Code:
select
concat ('$',yourcolumn)
from yourtable
 
im getting errors when i try to run the last one there
 
ok, that worked, but is it only temoporary or can i add it to each item permanently?
 
You aren't adding it to your table, you would add it every time you wanted to query your data and show the $ symbol in front of it.

Sorry about the space, I missed that.
 
thats ok, i guess ill just add it in on my http frontend. thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top