SELECT
amount,
rh.honoraria_key,
rh.honoraria_name
FROM
xref_speaker_honoraria sh
INNER JOIN xref_contract_speaker xcs ON (
sh.contract_id = xcs.contract_id)
INNER JOIN xref_contract_bureau xcb ON (
xcs.contract_id = xcb.contract_id)
INNER JOIN ref_contract c ON (xcs.contract_id = c.contract_id)
INNER JOIN ref_honoraria rh ON (
sh.honoraria_id = rh.honoraria_id AND
rh.display_ext>0)
WHERE
sh.speaker_id = 888 AND
xcb.brand_id = 27
AND CAST(c.`start` AS DATE) < '2014-13-02'
AND CAST(c.`end` AS DATE) > '2014-13-02'
GROUP BY
rh.honoraria_key
ORDER BY
rh.display_ext
我有上面提到的查詢,由於日期問題它沒有返回結果。如果我刪除AND CAST(c.
結束AS DATE) > '2014-13-02'
它的作品,但我想在兩個日期之間得到結果。 c.start和c.end的DATA類型是DATETYPE。mysql在日期間找到記錄
有沒有解決這個問題的任何提示?
您能分享一些樣本日期和您試圖實現的結果嗎?不確定我在追蹤... – Mureinik 2014-10-10 14:26:47
如果'start'和'end'已經是Date類型,那麼爲什麼CAST是DATE? – JNevill 2014-10-10 14:27:38
,因爲我比較日期不是日期類型,但它不工作沒有日期CAST也。 – kayra 2014-10-10 14:30:12