I'm wondering if you don't quite grasp how a union query works and how to build one (sorry if that's unfair) but my example below works.
It's simply two or more select queries that are strung together. Each gives you PART of what you want from a set of fields when data is in different columns of the same or multiple tables and is related to one or more fields from some other table(s). I put this together for you during commercials
.
Note: just make sure your trf and related fileds in table 2 are the same data type. I found that 8970564231 is large enough to be a double if it is a number type.
Code:
SELECT Table1.trf, Table2.Agent FROM Table1 INNER JOIN Table2 ON Table1.trf = Table2.Elec
UNION
SELECT Table1.trf, Table2.Agent FROM Table1 INNER JOIN Table2 ON Table1.trf = Table2.Gas
UNION
SELECT Table1.trf, Table2.Agent FROM Table1 INNER JOIN Table2 ON Table1.XX = Table2.XX
UNION
SELECT Table1.trf, Table2.Agent FROM Table1 INNER JOIN Table2 ON Table1.YY = Table2.YY;
Note that only the last statement contains the ending semicolon. Also, if you get duplicate records, you can try inserting the DISTINCT or DISTINCTROW clause:
(e.g. SELECT DISTINCT). However, I seem to recall reading that a union query only returns distinct records by design.
Post the union sql you tried if you want any analysis or comment on it.