[英]How can I copy from one mysql table to another table with different column type definitions?
I am trying to copy from one mysql table to another table with different column type definition... from varchar to int 我正在尝试从一个mysql表复制到具有不同列类型定义的另一张表...从varchar到int
I am trying to copy the column codigo which is a varchar, to codProducto in another table which is an int. 我正在尝试将作为varchar的codigo列复制到另一个int表中的codProducto中。
This is what I tried so far: 这是我到目前为止尝试过的:
INSERT INTO PRODUCTOS (codProducto)
SELECT CAST(codigo as SIGNED)
FROM desarrolloproductos;
ERROR 1292 (22007): Truncated incorrect INTEGER value: ''
INSERT INTO PRODUCTOS (codProducto)
SELECT CONVERT(codigo, UNSIGNED)
FROM desarrolloproductos;
ERROR 1292 (22007): Truncated incorrect INTEGER value: ''
any suggestions? 有什么建议么?
The problem was some lost wrong characters at the varchars column. 问题是在varchars列丢失了一些错误的字符。 Also after that, I realised that the string representation was bigger than a normal int, so I had to change the type to bigint .
同样在那之后,我意识到字符串表示形式比普通的int更大,因此我不得不将类型更改为bigint。 problem solved, thank you –
问题已解决,谢谢–
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.