Viet
Viet

Reputation: 6943

mySQL insert column with data from one table to another

I need to create a new table (table 2) with the data from an existing column of table 1:

Table 1:

id1 | item | type

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

1 | item 1 | type B

2 | item 2 | type A

3 | item 3 | type A

4 | item 4 | type B

5 | item 5 | type C

Table 2:

id2 | type | count

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

1 | type B | 2

2 | type A | 2

3 | type C | 1

id1 is not the same as id2

I've searched for answers and tried using: SET, UPDATE, INSERT JOIN with AS and FROM like some answers suggested but none of them works for me. How do I do it?

I used these keywords for my search: mysql create table with existing column, copy column from another table, insert column from another table, update column data from another table column...

Upvotes: 0

Views: 126

Answers (1)

emjr
emjr

Reputation: 232

Hi just use a view table

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

hope this helps :)

Upvotes: 1

Related Questions