我有两张桌子:
页1
+---------------+-------------+
| id | int |
+---------------+-------------+
| content | medium_text |
+---------------+-------------+
| date_modified | int |
+---------------+-------------+
页2
+---------+-------------+
| id | int |
+---------+-------------+
| content | medium_text |
+---------+-------------+
| date | int |
+---------+-------------+
我无法将content
表中的date_modified
和pages1
列复制到{{1}中的content
和date
列表格。
我收到pages2
错误,并且我尝试使用Unknown column
(别名),以防它不匹配,尽管我100%确定列存在。我使用了令人讨厌的蜱和整个九码:
AS
答案 0 :(得分:1)
尝试此查询:
INSERT INTO pages2 (`content`, `date`)
SELECT `content`, `date_modified` FROM `pages` WHERE `pages2`.`id` = `pages`.`id`;
答案 1 :(得分:1)
INSERT INTO pages2 (`content`, `date`)
SELECT `content`, `date_modified` FROM `pages`
答案 2 :(得分:0)
INSERT INTO pages2 (`content`, `date`)
SELECT `content`, `date_modified`
FROM `pages`
inner join pages2 on `pages`.`id` = `pages2`.`id`;