开发者

Way to copy the values from column1(containing numbers) declared as varchar to another column2 declared as number in Mysql

I am using a table say employee, which has two columns-mobileno and landlineno (both declared as varchar) contains the contact number of that employee. So now we are moving a step ahead by adding two additional columnms mn and fn both declared as bigint. So I wrote an update query which updated the values. Since the table has grown large, so it contains many junk values like 052-12525, which was inserted from from frontend, the value copied in mn is 052 ignoring the digits after "-". And 1 more instance is the mobileno is 5.836 which was incorrectly entered from front end was copied as 6. So please suggest me if there is a way in which the characters can be ignored and only the digits should be copied 开发者_如何学编程to the new column


use FORMAT and REPLACE

SELECT REPLACE('052-12525', '-', ''), FORMAT(12332.1,0)

will return 05212525 and 12332

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜