Insert Union Multiple Tables

I have a db with multible dbs and a single table type in it pertaining to the db. I’m trying to do a union on insert with a query built with a loop but I’m getting an error about syntax around the first union.

INSERT INTO website_user_education_edgsqthfrvj_1.user_education_erg5grsgrfgee_1(user_token, startYear, endYear, degree, shool, description, token) VALUES ('', '', '', '', '', '', '') UNION INSERT INTO website_user_education_edgsqthfrvj_2.user_education_erg5grsgrfgee_2(user_token, startYear, endYear, degree, shool, description, token) VALUES '', '', '', '', '', '', '') UNION INSERT INTO website_user_education_edgsqthfrvj_3.user_education_erg5grsgrfgee_3(user_token, startYear, endYear, degree, shool, description, token) VALUES ('', '', '', '', '', '', '')

You don’t need to use UNION to make three inserts. Just run the three inserts one after the other. Union is typically used in select statements to combine result sets.

3 Likes