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; 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
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
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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.