开发者

SQL: Records showing blank during the execution of a query

开发者 https://www.devze.com 2023-03-01 20:54 出处:网络
I am executing a query Select * from Parking Where ParkingStartTime <> \'08:00:00.0000000\' AND ParkingStartTime IS NULL

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.

SQL: Records showing blank during the execution of a query


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消