I want two lists, that both show records from their respective tables that are not being used another table.
Two lists, one for the table a_aif and one for the table a_proxy. The list to show only those fee_source_id's that are not present in the column a_fees.fee_source
Here is what I have so far (two separate queries). Any way to make a view with these two lists in separate columns?
SELECT a_aif.fee_source_id
FROM a_aif, a_fees
WHERE a_fees.fee_source NOT IN (SELECT a_aif.fee_source_id);
SELECT a_proxy.fee_source_id
FROM a_proxy, a_fees
WHERE a_fees.fee_source NOT IN (SELECT a_proxy.fee_source_id);
This method should be pretty agnostic to the RDBMS you are using.
A pair of
LEFT JOINs from which you select records where the right side isNULLwill do. AUNIONquery is used to build a master list of ids from both thea_aifanda_proxytables.http://sqlfiddle.com/#!2/cc170/3