简体   繁体   English

如何从一个mysql表复制到具有不同列类型定义的另一张表?

[英]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.

相关问题 如何将一列从一个表复制到另一个表 - How can I copy a column from one table to another 将一列复制到另一张表中的mysql - Copy one column to another in different table mysql 将一列从一个表复制到mysql中的另一个表(两个不同的数据库) - Copy a column from one table to another in mysql (two different databases) MySql中如何将列数据从一张表复制到另一张表? - How to Copy Column data from one table to another table in MySql? 如何使用MySQL将一个表的一个列(字段)复制到另一个表的空列(字段),这两个表都是同一数据库的一部分? - How can I copy one column (field) from one table to an empty column (field) of another table both of which are part of same database using MySQL? MySql表类型,如何将列数据从一个表自动绘制到另一个表? - MySql table type, how do I draw column data from one table to another automatically? MYSQL:如何将整行从一个表复制到 mysql 中的另一个表,第二个表有一个额外的列? - MYSQL: How to copy an entire row from one table to another in mysql with the second table having one extra column? 使用MySQL将数据从一列复制到另一张表中的另一列 - Copy Data from one column to another column in a different table using MySQL 如何将具有不同列数的行从一个表复制到另一表 - How can I copy rows from one to another table with a different number of columns 如何使用不同的 colnm 数据将行从一个表复制到另一个表 - How can I copy rows from one to another table with a different colnm data
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM