I’m pretty darn new to Access developement. Yesterday, I developed a query and in the WHERE portion, I used “&” as in :
WHERE ((condition A Is Null) & (condition B Is Null))
It returned 53 hits.
Then I changed it to
WHERE ((condition A Is Null) AND (condition B Is Null))
and got 71 hits.
I know it has to do with ‘bitwise and’ vs ‘logical and’, but can someone take a moment to explain this to me in noobish (English)?
ANDis a logical operator.&is a concatenation operator. Review Table of operators for more details about the various operators available in Access 2007.To see the differences in action, start with this as table
WeinerDog.The blanks in the
field1andfield2columns represent Null values.Next run this query:
That query should give you this result set:
Examine the
concat_resultcolumn. It contains strings which are the truth values of the 2 expressions concatenated together. Those truth values are either True (-1) or False (0). However, since the result of concatenation must be a string, the numeric truth values are first cast as strings before they are joined together.Then examine the
WHEREclause. The db engine will give you all rows for which theWHEREclause evaluates asTrue. And actually, not just -1, but any non-Null value other than zero can stand in forTrue. As you can see from theconcat_resultcolumn, none of those rows will be evaluated as zero (False) by theWHEREclause … so all rows in the table will be included in the query result set.If you change the
WHEREclause to substituteANDfor&, the query will return only theWeinerDogrow (id=3) which has Null for bothfield1andfield2.