MySql 5.1.x: insert into select .. encode strings
i have开发者_StackOverflow中文版 2 table with the same DEFAULT CHARSET=latin1 If i copy some data from one table to the another with the command 'Insert into () Select ()', MySql encode the strings. Example:
2461/P/J- -- RESO N° RM10
became 2461/P/J- -- RESO N° RM10
note the conversion from °
to °
How can avoid this? tnx in advice.
That doesn't happen when I try it (MySQL 5.1.41). Are you doing this directly from the MySQL console, or are you perhaps doing it via the MySQL API - perhaps from PHP?
Example:
CREATE TABLE `src` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`data` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `dst` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`data` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
INSERT INTO src (data) VALUES ('2461/P/J- -- RESO N° RM10');
SELECT * FROM src;
+----+----------------------------+
| id | data |
+----+----------------------------+
| 1 | 2461/P/J- -- RESO N° RM10 |
+----+----------------------------+
INSERT INTO dst SELECT * FROM src;
SELECT * FROM dst;
+----+----------------------------+
| id | data |
+----+----------------------------+
| 1 | 2461/P/J- -- RESO N° RM10 |
+----+----------------------------+
Can you verify the data in the original table? If you were having charset encoding issues, you would be seeing gargage characters and the like, not HTML entites. MySQL does not convert from/to HTML/XML entities as your example suggests.
精彩评论