mysql问题求解
表1:字符集latin1_swedish_ci,有字段:user,password,email,qq,msn等等
表2:字符集gbk_chinese_ci,有字段:user,password,email 用户到时要求要从表2中读取。 请问如何将表1中的记录插入到表2?最好是能写出语句,万分感谢
表1:字符集latin1_swedish_ci,有字段:user,password,email,qq,msn等等
表2:字符集gbk_chinese_ci,有字段:user,password,email 用户到时要求要从表2中读取。 请问如何将表1中的记录插入到表2?最好是能写出语句,万分感谢
+----------+-------------+-------------------+------+-----+---------+-------+---
| Field | Type | Collation | Null | Key | Default | Extra | Pr
+----------+-------------+-------------------+------+-----+---------+-------+---
| user | varchar(10) | latin1_swedish_ci | YES | | NULL | | se
| password | varchar(10) | latin1_swedish_ci | YES | | NULL | | se
| email | varchar(10) | latin1_swedish_ci | YES | | NULL | | se
| qq | varchar(10) | latin1_swedish_ci | YES | | NULL | | se
| msn | varchar(10) | latin1_swedish_ci | YES | | NULL | | se
+----------+-------------+-------------------+------+-----+---------+-------+---
5 rows in set (0.02 sec)mysql> show full columns from t_gzhuu2;
+----------+-------------+----------------+------+-----+---------+-------+------
| Field | Type | Collation | Null | Key | Default | Extra | Privi
+----------+-------------+----------------+------+-----+---------+-------+------
| user | varchar(10) | gbk_chinese_ci | YES | | NULL | | selec
| password | varchar(10) | gbk_chinese_ci | YES | | NULL | | selec
| email | varchar(10) | gbk_chinese_ci | YES | | NULL | | selec
+----------+-------------+----------------+------+-----+---------+-------+------
3 rows in set (0.00 sec)mysql> insert into t_gzhuu1 (user,password,email)
-> select unhex(hex(user)),password,email from t_gzhuu2;
Query OK, 2 rows affected (0.09 sec)
Records: 2 Duplicates: 0 Warnings: 0mysql>
Empty set (0.00 sec)mysql> select * from t_gzhuu2;
+-------+----------+-----------+
| user | password | email |
+-------+----------+-----------+
| 记录1 | 123 | [email protected] |
| 记录2 | 124 | [email protected] |
+-------+----------+-----------+
2 rows in set (0.00 sec)mysql> insert into t_gzhuu1 (user,password,email)
-> select unhex(hex(user)),password,email from t_gzhuu2;
Query OK, 2 rows affected (0.03 sec)
Records: 2 Duplicates: 0 Warnings: 0mysql> set names 'latin1';
Query OK, 0 rows affected (0.00 sec)mysql> select * from t_gzhuu1;
+-------+----------+-----------+------+------+
| user | password | email | qq | msn |
+-------+----------+-----------+------+------+
| 记录1 | 123 | [email protected] | NULL | NULL |
| 记录2 | 124 | [email protected] | NULL | NULL |
+-------+----------+-----------+------+------+
2 rows in set (0.00 sec)mysql>