Suppose you have a table with 2 columns one int and other varchar. Now if you want to update varchar fields in all the records with the int value, use this query :
update table_name set varchar_Field = CAST(int_Field AS CHAR);
If you want to some text in addition to the int field, then use :
update table_name set varchar_Field = CONCAT(CAST(int_Field AS CHAR), 'sampleText');
7 comments:
+1 :)
thanks for this helpful post..
Thanks much :D
Wat about converting a string to an integer?
how to convert text column to number. say for i want to get max of a varchar column which actually contains numbers as values.
Just wanted to say thanks for this tip. I was trying to use the REPLACE function on an INT field. It worked in HeidiSQL, a MySQL frontend app. But, I got errors when I ran the same statement using VBA. Thanks to your post, it worked. Again, thanks!
Post a Comment