mysql> SELECT CONCAT ( CAST(1 as char) , '2') AS test
+------+
| test |
+------+
| 12 |
+------+
1 row in set (0.00 sec)
mysql> SELECT CONCAT ( Convert(1, char) , '2') AS test
+------+
| test |
+------+
| 12 |
+------+
1 row in set (0.00 sec)
字符转数字
mysql> SELECT CAST('1' as SIGNED) + 100 AS test
+------+
| test |
+------+
| 101 |
+------+
1 row in set (0.00 sec)
mysql> SELECT Convert('1' , SIGNED) + 100 AS test
+------+
| test |
+------+
| 101 |
+------+
1 row in set (0.00 sec)
由于工作需要,经常需要将mysql数据库中的数据导出到excel表格,或者需要将excel表格数据导入到mysql数据库,我的方法是先将它们都转换成一种中间数据格式csv(execl数据可以直接导出为csv格式,csv格式也可以直接用excel打开)。下面介绍一下 *** 作步骤:csv导入mysqlloaddatainfile'C:\\Users\\UserName\\Desktop\\test.csv'intotable`table`fieldsterminatedby','optionallyenclosedby'"'escapedby'"'linesterminatedby'\n'mysql导入csvselect*from`table`loaddatainfile'C:\\Users\\UserName\\Desktop\\test.csv'fieldsterminatedby','optionallyenclosedby'"'escapedby'"'linesterminatedby'\n'如果乱码,可用相关编辑器打开.csv文件,另存为utf-8的csv欢迎分享,转载请注明来源:内存溢出
评论列表(0条)