Skip to content
Advertisement

Joining two tables with same keys but different fields

I have two tables both all with the same fields Except for one. I want to combine these two tables with the resulting table having all the fields from both including the two fields that are not the same in each table. I.e:

lets say I have table order_debit with schema

and table order_credit with schema

What I want is a final table with the schema

I cant figure out how to do the joins without getting duplicate values, I dont think there will be too many overlaps of order_ids but there will definitely be some.

Advertisement

Answer

For MySQL, you can use UNION ALL and GROUP BY

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement