[英]Insert data in a table from two other tables
I need to insert data in a table from two other tables that have the same schema. 我需要从其他两个具有相同架构的表的表中插入数据。
I have an exception : 我有一个例外:
You have an error in your SQL syntax; 您的SQL语法有误; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FULL JOIN data e2 ON e1.siren = e2.siren' at line 3 检查与您的MySQL服务器版本对应的手册以获取正确的语法,以在第3行的“ FULL JOIN data e2 ON e1.siren = e2.siren”附近使用
Here's My code : 这是我的代码:
string MergeTables = string.Format(@"INSERT INTO Table3 (a,b)
SELECT e1.a, e2.b
FROM bilan e1 FULL JOIN data e2
ON e1.id= e2.id;
");
Try to remove ;
尝试删除;
at the end of your sql and remove FULL
due to MySQL
do not support FULL JOIN
在您的SQL末尾并由于MySQL
不支持FULL JOIN
删除FULL
string MergeTables = string.Format(@"INSERT INTO exercices (AF,region)
SELECT e1.AF, e2.region FROM bilan e1
JOIN data e2 ON e1.siren = e2.siren
");
MySQL does not support FULL JOIN
MySQL不支持 FULL JOIN
Try to emulate it as follows: 尝试模拟如下:
SELECT e1.AF FROM bilan e1
LEFT JOIN data e2 ON e1.siren = e2.siren
UNION
SELECT e2.region FROM data e2
RIGHT JOIN bilan e1 ON e2.siren = e1.siren
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.