0
我可以得到一些幫助來清理以下查詢並可能將其轉換爲連接。將查詢轉換爲加入
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的專家很抱歉,如果我已經做錯了什麼
正如tombom解釋的那樣,您的WHERE子句是一團糟。這個怎麼樣。而不是你不想要的東西,你試圖在折扣中找到什麼被排除在外。看起來,你希望任何發現STARTED至少爲4/15的工作,並且是在4/17或之前完成的。如果是這樣,這些是您想要從結果中「忽略」的屬性。這是否準確? – DRapp 2012-04-13 13:28:25