I have a query A like this:
SELECT * FROM my_table WHERE foreign_key = 'abc' AND field1 = 'foo' AND field2 = 'bar';
Is there a way to find out which part of the where clause was responsible for the exclusion of data compared to a superset of the data? For example compared to query B:
SELECT * FROM my_table WHERE foreign_key = 'abc';
I know that you could take every part of the where clause in a seperate query and take the difference quantity of query B. Is there a more efficient way to do this or a best practice?
The goal is to mark the excluded data rows with a reason for their exclusion.