在预期条件的上下文中指定的非布尔类型的表达式

时间:2013-03-11 23:49:06

标签: sql wpf database visual-studio-2010

在上下文中指定的非布尔类型的表达式,当我将鼠标悬停在顶行时预期条件,请参阅图像:

Sql image problem

SELECT Bookings.Date, Bookings.Timebegan, Bookings.Timefinished, Bookings_1.Date, Bookings_1.Timebegan, Bookings_1.Timefinished, 
              Bookings.RoomID, Bookings_1.RoomID
FROM     Bookings,
              Bookings AS Bookings_1
WHERE Not Nz(([Bookings_1].[Timebegan]>=[Bookings].[Timefinished]) Or
  ([Bookings_1].[Timefinished]<=[Bookings].[Timebegan]) Or
  ([Bookings].[RoomID]!=[Bookings_1].[RoomID]) Or
  ([Bookings].[ID]=[Bookings_1].[ID]),False)
ORDER BY Bookings.ID, Bookings_1.ID;

有人有任何想法吗?

1 个答案:

答案 0 :(得分:0)

好谜语(De Morgan的法律提醒;))。试试这个:

WHERE  
    (
        [Bookings_1].[Timebegan] is NULL
        OR [Bookings].[Timefinished] is NULL
        OR [Bookings_1].[Timefinished] is NULL
        OR [Bookings].[Timebegan] is NULL
        OR [Bookings].[RoomID] is NULL
        OR [Bookings_1].[RoomID] is NULL
        OR [Bookings].[ID] is NULL
        OR [Bookings_1].[ID] is NULL
        OR 
        (
         [Bookings_1].[Timebegan]<[Bookings].[Timefinished]
         AND [Bookings_1].[Timefinished]>[Bookings].[Timebegan] 
         AND [Bookings].[RoomID]=[Bookings_1].[RoomID]
         AND [Bookings].[ID]<>[Bookings_1].[ID]
        )
    )