MySQL-组合2个类似的表
我有以下两个表,我想把表2的内容添加到表1的末尾(例如:将两个表合并为1)。希望ID继续自动递增 表1:MySQL-组合2个类似的表,mysql,Mysql,我有以下两个表,我想把表2的内容添加到表1的末尾(例如:将两个表合并为1)。希望ID继续自动递增 表1: CREATE TABLE IF NOT EXISTS `world` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `country` varchar(2) DEFAULT NULL, `region1` varchar(60) DEFAULT NULL, `region2` varchar(60) DEFAULT
CREATE TABLE IF NOT EXISTS `world` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`country` varchar(2) DEFAULT NULL,
`region1` varchar(60) DEFAULT NULL,
`region2` varchar(60) DEFAULT NULL,
`region3` varchar(60) DEFAULT NULL,
`zip` varchar(10) DEFAULT NULL,
`city` varchar(60) DEFAULT NULL,
`latitude` double DEFAULT NULL,
`longitude` double DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5871647 ;
表2:
CREATE TABLE IF NOT EXISTS `extra` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`country` varchar(2) DEFAULT NULL,
`city` varchar(60) DEFAULT NULL,
`latitude` double DEFAULT NULL,
`longitude` double DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=687421 ;
玩过以下游戏:
INSERT INTO world (country, city, latitude, longitude)
VALUES SELECT country, city, latitude, longitude FROM extra;
thx试试这个
INSERT INTO world (country, city, latitude, longitude)
SELECT country, city, latitude, longitude FROM extra;
尝试不使用下面的值
有任何错误或您所期望的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,了解在第2行“从额外值中选择国家、城市、纬度、经度”附近使用的正确语法,我认为不需要这些值
INSERT INTO world (country, city, latitude, longitude)
SELECT country, city, latitude, longitude FROM extra;