I am not asking due to a specific problem but out of general interest. I
have
been using both not and <> in the criteria row of the design grid of my
queries interchangeably as it has always yielded same results. I was
curious
exactly because of this reason: if they have been yielding same results,
was
that just because of the specific data sets that I have dealt with or
could I
ever encounter a case where results would be different with <> and "not"
and
my results would be erroneous because I chose the wrong one randomly.
Ken has written that the difference will depend upon the data type of
values. How does data type affect the difference in results of not and <>
?
To take a simple example, say there is a table Months with 2 fields: Month
and Month Number with these values:
Month Number Month
1 January
2 February
....
12 December
I have the following 2 queries one with <> and the other with "not"
Query1:
SELECT Months.Month, Months.[Month Number]
FROM Months
WHERE (((Months.[Month Number])<>"1"));
Query2:
SELECT Months.Month, Months.[Month Number]
FROM Months
WHERE ((Not (Months.[Month Number])="1"));
Both queries produce the same results that is all months except January. I
have always found the results to be the same using <> and not in the above
way.
Can the results ever be different using <> and not in this way and if yes,
what would that case be? Thanks.
Chris M said:
Can't really think how <> and NOT are interchangable, unless he is asking
if
'NOT(a=b) is the same as (a<>b)?
Those 2 are logically equivilent and will always produce the same result.
Neeraj: Are you asking this due to a specific problem you have, or just
general interest?