我可以获得一些帮助来清理以下查询并可能将其转换为联接。
SELECT pd.id, pd.title, pd.vacation_type_ids, pd.auto_vacation_theme
FROM property_details pd
WHERE pd.company_id =247
AND pd.status = "active"
AND pd.id NOT
IN (
SELECT d.property_id
FROM property_discount d
WHERE (
(
d.start_date <= CAST( "2012-04-15" AS DATE )
AND d.end_date >= CAST( "2012-04-15" AS DATE )
AND d.start_date <= CAST( "2012-04-17" AS DATE )
AND d.end_date >= CAST( "2012-04-17" AS DATE )
)
OR (
d.start_date >= CAST( "2012-04-15" AS DATE )
AND d.start_date <= CAST( "2012-04-17" AS DATE )
)
OR (
d.end_date >= CAST( "2012-04-15" AS DATE )
AND d.end_date <= CAST( "2012-04-17" AS DATE )
)
)
)
我不是 MySQL 专家,如果我做错了什么,我很抱歉