In the mysql tutorial, data tables are merged and only one duplicate data is read.
// First, let's take a look at the mysql SQL structure and use union Joint queries and insert into to replicate the whole table.
Mysql_connect ("localhost", "root", "root") or die ('database Server Uid or Password Error! ');
Mysql_select_db ('IP') or die ('data! ');
Mysql_query ("set names 'gb2312 '"); // SET the encoding of the document and the database tutorial to be consistent. Otherwise, garbled characters may occur.
/*
First, create tables a111cnnet, b111cnnet, and c111cnnet. Now I want to import b111cnnet and c111cnnet to a111cnnet. If the two tables have the same records, only one record is saved.
The structure of the three tables is the same as follows:
Id mediumint (8) UNSIGNED no 0
Fid smallint (6) UNSIGNED no 0
Allowview tinyint (1) No 0
Allowpost tinyint (1) No 0
Allowreply
Table b111cnNet records
1, 2, 3, 6, 4
2, 3, 6, 5, 4
Table c111cnNet records
1, 2, 3, 4, 5
4, 6, 5, 2, 8
Now let's query
*/
$ SQL = "insert into a111cnNet (select * from b111cnNet) union (select * from c111cnNet) as tt group by id )";
Mysql_query ($ SQL); // The result is
/*
Table a111cnNet records
1, 2, 3, 4, 5
2, 3, 6, 5, 4
4, 6, 5, 2, 8
Analysis
Insert into full table Import
Union Joint Query
The original article on this site is reprinted to indicate that it is from www. bKjia. c0m
*/