LifeinAsia

msg:4531158 | 5:27 pm on Dec 26, 2012 (gmt 0) |
If you want to sort the numbers, you'll need to use a numeric type (int, etc.). Use the Format() function to format the numbers with commas when displaying them.
|
tongpo

msg:4531161 | 5:33 pm on Dec 26, 2012 (gmt 0) |
THe numbers in question come from a third party source already formatted with thousandths as 1,200 etc. So its not a question really of inputting them as 1200 and displaying them with commas. I just want to be able to input them as I receive them i.e 1,300 into database and then be able to sort them by asc/desc correctly which obviously storing them as varchar does not do.
|
tongpo

msg:4531162 | 5:38 pm on Dec 26, 2012 (gmt 0) |
And int etc does not insert them correctly, I guess Im just going to have to alter them before insertion so 1,200 becomes 1200.
|
LifeinAsia

msg:4531164 | 6:04 pm on Dec 26, 2012 (gmt 0) |
You'll need to either: A) Strip the commas when you import them as INT, or B) Import them as VARCHAR then strip the commas and save into a different field (type INT).
|
brotherhood of LAN

msg:4531165 | 6:10 pm on Dec 26, 2012 (gmt 0) |
| A) Strip the commas when you import them as INT, or |
| I'd go for LifeinAsia's A) suggestion, as it's trivial to replace the commas while performing operations on a smaller and fixed length field has its advantages.
|
tongpo

msg:4531166 | 6:16 pm on Dec 26, 2012 (gmt 0) |
Yea thanks, just done that, works as I want now: $variable = str_replace(',', '', $variable);
|
|