mySQL插入列,其中包含从一个表到另一个表的数据

时间:2017-10-25 00:34:22

标签: mysql

我需要使用表1现有列中的数据创建一个新表(表2):

表1:

id1 |项目|型

=============

1 |第1项| B型

2 |第2项|输入A

3 |第3项|输入A

4 |第4项| B型

5 |第5项| C型

表2:

id2 |类型|计数

===================

1 | B型| 2

2 |输入A | 2

3 |键入C | 1

id1与id2

不同

我已经搜索了答案并尝试使用:SET,UPDATE,INSERT JOIN AS和FROM就像一些答案所示,但它们都不适合我。我该怎么做?

我在搜索中使用了这些关键字:mysql create table with existing column,copy column from another table,insert column from another table,update column data from another table column ...

1 个答案:

答案 0 :(得分:1)

您只需使用视图表

https://www.w3schools.com/sql/sql_view.asp

希望这有助于:)