At present, I have two data sheet structure is the same, now I want to merge two tables into a table, but in the phpmyadmin it seems not to find how to merge the options, the Web also search some merged SQL statements, but after the execution of the error, do not know what the reason, there is no other way to achieve
INSERT INTO order_zong (Ptname, Name, Mobile, orderdate, orderprice, ordertime) VALUES ( SELECT Ptname, Name, Mobile, orderdate, orderprice, ordertime from hnb);
The above code error 12 errors, probably the way is not right, trouble master to give a simple way
Reply content:
At present, I have two data sheet structure is the same, now I want to merge two tables into a table, but in the phpmyadmin it seems not to find how to merge the options, the Web also search some merged SQL statements, but after the execution of the error, do not know what the reason, there is no other way to achieve
INSERT INTO order_zong (Ptname, Name, Mobile, orderdate, orderprice, ordertime) VALUES ( SELECT Ptname, Name, Mobile, orderdate, orderprice, ordertime from hnb);
The above code error 12 errors, probably the way is not right, trouble master to give a simple way
If the data structure is the same, the following can be:
INSERT INTO `your_table_name`SELECT *FROM `destination_table_name`;
INSERT into C Select from a UNION select from b
Export SQL Merge after import haha
Insert into Table2(field1,field2,...) select value1,value2,... from Table1
INSERT IGNORE INTO order_zong (Ptname, Name, Mobile, orderdate, orderprice, ordertime) SELECT Ptname, Name, Mobile, orderdate, orderprice, ordertime from hnb;
If the table is re-inserted, insert into will not use values, but direct select table.
Note: You may have an error when inserting a primary key that repeats itself.
Can you put out the mistake? Will some fields define a unique. So the import uniqueness conflict is wrong.
or create a new table to merge
If you need to go heavy, use union.
create table new_table SELECT Ptname, Name, Mobile, orderdate, orderprice, ordertime from order_zong union all SELECT Ptname, Name, Mobile, orderdate, orderprice, ordertime from hnb