我需要从输入的日期和时间到剩下的日期和时间获取用户列表(如果没有输入日期和时间,也要给出结果)。此查询的结果有问题,尤其是当我在/左侧键入日期/时间时。搜索表单适用于其余字段(如名称、车辆编号、级别、单位)。
SELECT * FROM "tblVehicles"
WHERE
((UPPER("Name") LIKE '%' ||
UPPER(:VAR_NAME) || '%')
OR
(:VAR_NAME is NULL))
AND
((UPPER("Vehicle Number") LIKE '%' ||
UPPER(:VAR_VEHICLE) || '%')
OR
(:VAR_VEHICLE is NULL))
AND
((UPPER("Level") LIKE '%' ||
UPPER(:VAR_LEVEL) || '%')
OR
(:VAR_LEVEL is NULL))
AND
((UPPER("Unit") LIKE '%' ||
UPPER(:VAR_UNIT) || '%')
OR
(:VAR_UNIT is NULL))
AND
((("Date In" >= :VAR_DATEIN) AND ("Time In" >= :VAR_TIMEIN))
OR
((:VAR_DATEIN is NULL)
OR
(:VAR_TIMEIN is NULL)))
AND
((("Date Left" <= :VAR_DATELEFT) AND ("Time Left" <= :VAR_TIMELEFT))
OR
((:VAR_DATELEFT is NULL)
OR
(:VAR_TIMELEFT is NULL)))