I have a table in which i have multiple entries against a FK. I want to find out the value of FK which do not have certain entries e.g
my table has following entries.
PK----------------FK-----------------Column entries 1----------------100-----------------ab1 2----------------100-----------------ab2 3----------------100-----------------ab4 4----------------200-----------------ab1 5----------------200-----------------ab2 6----------------200-----------------ab3 7----------------300-----------------ab1 8----------------300-----------------ab2 9----------------300-----------------ab3 10---------------300-----------------ab4
Now, from this table i want to filter all those FK which do not have ab3 or ab4 in them. Certainly, i expect distinct values i.e. in this case result would be FK= 100 and 200.
The query which i am using is
select distinct(FK)
from table1
where column_entries != 'ab3'
or column_entries != 'ab4';
Certainly, this query is not fetching the desired result.
or;'ab3' != 'ab3' or 'ab3' != 'ab4'yields true, as well as'ab4' != 'ab3' or 'ab4' != 'ab4'. Useandor, to express intent more clearly,not in(but comparison list must not contain null).