vin
vin

Reputation: 562

Create a table as another table in mysql

I am trying to create a table(ie. test1) as another table(test2). test2 has all records. there are some duplicate records like below:

enter image description here

Now I want to all record of table test2 in table test1 like below (using create command):

enter image description here

Thanks in Advance

Upvotes: 4

Views: 325

Answers (1)

Łukasz W.
Łukasz W.

Reputation: 9755

With MySQL you probably could try like this:

INSERT INTO test1(id, name, address, mobile, genere) 
   SELECT id, name, address, mobile, genere 
   FROM test2 
   GROUP BY name, address, mobile, genere

or if you want a CREATE syntax try

CREATE TABLE test1 AS  
   (SELECT id, name, address, mobile, genere 
   FROM test2 
   GROUP BY name, address, mobile, genere)

Upvotes: 5

Related Questions