出于某种原因,运行以下代码时出现以下错误:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM postcodes_demographics INNER JOIN latlon1 on postcodes_demographics.postc' at line 3
我不明白我做错了什么,谢谢你提出任何建议!
INSERT INTO pslatlong
SELECT postcodes_demographics.*, latlon1.*,
FROM postcodes_demographics
INNER JOIN latlon1
on postcodes_demographics.postcode = latlon1.postcodens;
答案 0 :(得分:1)
你有一个错误的逗号:
SELECT postcodes_demographics.*, latlon1.*, <--- HERE
删除它。
答案 1 :(得分:1)
如果仅删除逗号可以修复问题,我会非常惊讶。使用insert
时,您应该养成明确列出所有列的习惯:
INSERT INTO pslatlong(col1, col2, . . . )
SELECT d.col1, l.col2, . . .
FROM postcodes_demographics d INNER JOIN
latlon1 ll
on d.postcode = ll.postcodens;
您需要这样做以确保为正确的列分配了正确的值,以允许自动递增列自动递增,并根据列数防止出现问题。
答案 2 :(得分:0)
这可能有效:
INSERT INTO pslatlong
SELECT postcodes_demographics.*, latlon1.*
FROM postcodes_demographics
INNER JOIN latlon1
on postcodes_demographics.postcode = latlon1.postcodens;