我被困在一条 SQL 语句上。我正在尝试获得以下信息:
Select fields from the rentedHouseTbl WHERE
一个属性匹配一个属性IDTr
**AND**
the rentedHouseMoveInDateTr is less than or equal to today's date AND
the rentedHouseMoveOutDateTr is NULL
OR
the rentedHouseMoveInDateTr is less than or equal to today's date AND
the rentedHouseMoveOutDateTr is greater than today's date.
If this returns results then the property is occupied
else it is vacant
我使用的 SQL 语句是:
SELECT * FROM rentedHouseTbl where propertyIDTr = '1' AND ( (rentedHouseMoveInDateTr <= CURDATE() AND rentedHouseMoveOutDateTr IS NULL) OR (rentedHouseMoveInDateTr <= CURDATE() AND rentedHouseMoveOutDateTr > CURDATE()) )
但我没有得到预期的结果。任何帮助,将不胜感激!