MySQL Tutorial datasheet merge and only duplicate data read only one
First we have to shield MySQL SQL structure, with union query and insert into to the whole table copy.
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 document and database tutorial code is OK, otherwise it will be garbled
/*
First we create the datasheet a111cnnet and b111cnnet,c111cnnet table, and now I'm going to import b111cnnet,c111cnnet into the A111cnnet table. And if two tables have the same record, save only one. The structure of the
Three tables is the same as the following
ID mediumint (8) UNSIGNED no 0 & nbsp;
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 check it out.
*/
$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
Analytical
Insert into full table import
Union Union query
This site original article reproduced annotated from Www.111cn.net
*/