Search code examples
mysqlsqlmysql-error-1222

Mysql error: 1222 when I am creating a new table from two existing tables


Mysql error: 1222 when I am creating a new table from two existing tables. This is my sql statement for creating a new table from two existing table. Please help me to find solution for this problem, Thanks

CREATE TABLE insurance_db.new_insurance 
SELECT * FROM insurance_db.auto_insurance
UNION all
SELECT * FROM insurance_db.home_insurance;  

Solution

  • Try this way

    CREATE TABLE insurance_db.new_insurance 
    As (SELECT col1, col2,.... FROM insurance_db.auto_insurance, insurance_db.home_insurance);