When building a query to display results from 2 tables where 2 are identical but the third is not (has fewer fields but does share the 4 columns which need to be returned in the result), what is the proper way to build the query?
Table1: sku field1 field2 field3 field 4 field 5 field 6 field 7
Table2: sku field1 field2 field3 field 4 field 5 field 6 field 7
Table3: sku field1 field2 field3 field 4
Both of these Fails of course:
SELECT * FROM table1 UNION SELECT * FROM table2 UNION SELECT * FROM table3 ORDER BY sku ASC
SELECT * FROM table1 UNION SELECT * FROM table2 UNION SELECT sku, field1, field2, field3, field4 FROM table3 ORDER BY sku ASC
in another SO post I saw where the query was using NULL AS fieldname to make the tables equal for the query but if table1 & table2 had say 80 fields and table3 had 5, does that mean I have to add NULL AS fieldname6...7...8....> for 75 fields?
Just a whim I tried it as below which also failed:
SELECT * FROM table1 UNION SELECT * FROM table2 UNION SELECT sku, field1, field2, field3, field4, NULL AS * FROM table3 ORDER BY sku ASC
Thanks for any help.