这有效
SELECT EntryId FROM 2_1_journal
WHERE CAST(CONCAT_WS('-', RecordYear,RecordMonth,RecordDay) AS DATE) = ?
但是之前想WHERE
用列名定义日期的“虚拟”列名,例如RecordDate
。
试过了
SELECT EntryId FROM 2_1_journal
CAST(CONCAT_WS('-', RecordYear,RecordMonth,RecordDay) AS DATE) RecordDate
WHERE RecordDate = ?
SELECT EntryId FROM 2_1_journal
CAST(CONCAT_WS('-', RecordYear,RecordMonth,RecordDay) AS DATE) AS RecordDate
WHERE RecordDate = ?
SELECT EntryId FROM 2_1_journal
CAST((CONCAT_WS('-', RecordYear,RecordMonth,RecordDay) AS DATE) AS RecordDate)
WHERE RecordDate = ?
在所有情况下都会出错Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CAST
。
请建议什么是正确的语法