We help IT Professionals succeed at work.

minus varchar mysql

teera
teera asked
on
field b is varchar but all of them is number   4.1  4 12.5  41 20 3.2   how can  minus  1 for all member
Comment
Watch Question

Billing Engineer
Most Valuable Expert 2014
Top Expert 2009
Commented:
why is the field varchar, if it contains all numbers?

anyhow, for the math/update, you do a cast:
http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html
update yourtable set yourfield = cast(yourfield as DECIMAL) -1

Open in new window


hope this helps
awking00Information Technology Specialist
Commented:
select convert(b,decimal) - 1