如何将 table 列数据添加到 mysql 中另一个类似的列 table
How to add table column data to another similar column table in mysql
我在不同的数据库中有两个相似的 table,而那些 table 具有相似的列。假设我有 Db 名称 image1
和 table 名称 tbl_image
以及列 id
、f_name
、l_name
并且 table 有更多大于 50 > 数据
我还有另一个 Db 名称 image2
和 table 名称 tbl_image
也有列 id
、f_name
、l_name
和那 table 也有超过 50 > 数据
我怎样才能将 image2
数据库 table 数据添加到 image1
数据库 table.can 谁能给我个主意。
如果两个表具有相同的结构(意味着它们的每一列也共享相同的类型),要合并两个表,您可以简单地使用
INSERT INTO image1.tbl_image SELECT * FROM image2.tbl_image
这假设两个表中的 id
不重叠。
如果你有重复项,但你没有绑定到这些值(你没有提到外键),你可以像这样从 image2.tbl_image
插入数据
INSERT INTO image1.tbl_image SELECT NULL,f_name,l_name FROM image2.tbl_image
这将为 image2.tbl_image
中的所有行提供一个新的 id
。
我在不同的数据库中有两个相似的 table,而那些 table 具有相似的列。假设我有 Db 名称 image1
和 table 名称 tbl_image
以及列 id
、f_name
、l_name
并且 table 有更多大于 50 > 数据
我还有另一个 Db 名称 image2
和 table 名称 tbl_image
也有列 id
、f_name
、l_name
和那 table 也有超过 50 > 数据
我怎样才能将 image2
数据库 table 数据添加到 image1
数据库 table.can 谁能给我个主意。
如果两个表具有相同的结构(意味着它们的每一列也共享相同的类型),要合并两个表,您可以简单地使用
INSERT INTO image1.tbl_image SELECT * FROM image2.tbl_image
这假设两个表中的 id
不重叠。
如果你有重复项,但你没有绑定到这些值(你没有提到外键),你可以像这样从 image2.tbl_image
插入数据
INSERT INTO image1.tbl_image SELECT NULL,f_name,l_name FROM image2.tbl_image
这将为 image2.tbl_image
中的所有行提供一个新的 id
。