I have been trying to get this query to work and hoping someone can give me some advice.
I have two tables. master and aux. I need master to be updated with any rows that are in aux and not in master based on groupid and section id.
I need to actually do this with multiple aux tables, but as long as I can figure out how to do it on one, I can just manually run the query on each table I need.
So far I've just been trying to use a select to get the data from aux that should be inserted into master. Once I have that I can modify it to create the insert query. (I hope)
select a.id from master as m, aux as a where a.gid = m.groupid and a.sid = m.sectionid and not in m.groupid and not in m.sectionid
This query is not working :(
id groupid sectionid 1 A Group 21 2 A Group 23 3 B Group 55 4 C Group 999 5 D Group 52A 6 D Group 53
id gid sid 1 A Group 21 2 A Group 22 3 A Group 23 4 B Group 55 5 B Group 55A 6 C Group 999 7 D Group 52A 8 D Group 53 9 D Group 56
master table after query
id groupid sectionid 1 A Group 21 2 A Group 23 3 B Group 55 4 C Group 999 5 D Group 52A 6 D Group 53 7 A Group 22 8 B Group 55A 9 D Group 56
Thank you in advance for any help.