Search code examples
mysqlsqlddlcreate-table

Short way to keep all fields in mySQL?


In MySQL I'm creating a table ts2 from another table ts1 by only keeping the distinct rows with the following command

CREATE TABLE ts2 AS SELECT DISTINCT 
name, date_of_birth, position, email, ... FROM ts1;

Is there a short way to indicate that I want to pick all fields?


Solution

  • You can use the * operator:

    CREATE TABLE ts2 AS SELECT DISTINCT * FROM ts1;