How can i convert a price field which is currently varchar to a decimal so my prices will order correctly?
I am using MYSQL.
I have a varchar field which i incorrectly used for a price. Now the ordering of this table will not work correctly putting anything over 1000 to the bottom of the list.
I need to convert this price field in an existing POPULATED database from varchar to decimal i guess?
Any help would be appreciated.
Simply use the ALTER TABLE statement.
If for example the table is called 'products' and the field is called 'product_price' you could simply use:
ALTER TABLE products MODIFY COLUMN product_price DOUBLE;
NB: As with anything, I'd be very tempted to make a backup of the data (via mysqldump) prior to performing this operation - it'll take seconds and it's always better to be safe rather than sorry. :-)