返回錯誤的值使用下面的查詢,我需要在本月「02」,只顯示標有年份「2014」的記載:MySQL查詢在where子句
SELECT DISTINCT
c.sno,
c.cCode,
c.caseNumber,
c.dateOriginalInstitution,
c.date_remanded,
c.plaintiff,
c.respondant
FROM
cases c,
chronologicallists ch
WHERE (
(YEAR(dateOriginalInstitution) = '2014' AND MONTH(dateOriginalInstitution) = '02')
OR
(YEAR(dateOfTransferInstituion) = '2014' AND MONTH(dateOfTransferInstituion) = '02')
OR
(YEAR(date_restored) = '2014' AND MONTH(date_restored) = '02')
)
AND c.inTheCourt = '578' AND c.sno = ch.caseSno
我m仍然在2011和2012年的結果集?
請幫我這個。
顯示'dateOfTransferInstituion'列,我猜它必須有「2014」記錄。 – Rikesh
也許你應該使用'LIKE'子句中有比較,如果'dateOfTransferInstitution'也有類似的期待日期戳'dateOriginalInstitution'例如'dateOriginalInstitution LIKE「2014-02 - %」' – pythonian29033