I am executing a query
Select *
from Parking
Where ParkingStartTime <> '08:00:00.0000000'
AND ParkingStartTime IS NULL
In return to the execution, the columns names a开发者_如何学Cre displayed but there records are not showing.
If I used OR Rather than AND it works. Any idea of why AND is not working?
Regards.
This can never return any results. The 2 conditions are contradictory.
If ParkingStartTime IS NULL
then ParkingStartTime <> '08:00:00.0000000'
will evaluate to unknown
.
True and Unknown
evaluates to Unknown
under the truth tables for 3 valued logic.
If ParkingStartTime is null, it can't have a value. This means that any value that meets the first part of the query cannot meet the second part of the query.
You either need just
ParkingStartTime is null
or
ParkingStartTime <> '08:00:00.000000'
ParkingStartTime cannot be both NULL (unknown) and also be equal to a particular value e.g. 08:00:00.0000000
The query does not return any values because your logic is incorrect.
精彩评论