我的查询是-
SELECT ins.*, ic.*
FROM insurance_data AS ins
LEFT JOIN insurance_companies AS ic ON ins.provider = ic.id
LEFT JOIN phone_numbers AS ph ON (ic.id = ph.foreign_id AND ph.type = 2)
WHERE (ins.termination_date IS NULL OR ins.termination_date = "" OR
ins.termination_date = "0000-00-00") AND ins.provider IS NOT NULL
AND ins.provider > 0
ORDER BY ins.date DESC LIMIT 1
我已经在 MySQL 中设置了 SQL 模式 更改为“ALLOW_INVALID_DATES、ONLY_FULL_GROUP_BY、ERROR_FOR_DIVISION_BY_ZERO、NO_ENGINE_SUBSTITUTION”。 但我仍然收到错误错误代码:1525。不正确的日期时间值:''。
我在 Windows 10 上使用 MySQL 版本 8.0.35。我正在 MySQL Workbench 中运行查询。
我修改了查询,删除了对
''
字段中空字符串 (termination_date
) 的检查,仅关注 NULL
和大于 '0000-00-00'
的有效日期。希望这有助于修复错误>>
SELECT ins.*, ic.*
FROM insurance_data AS ins
LEFT JOIN insurance_companies AS ic ON ins.provider = ic.id
LEFT JOIN phone_numbers AS ph ON (ic.id = ph.foreign_id AND ph.type = 2)
WHERE (ins.termination_date IS NULL OR ins.termination_date > '0000-00-00')
AND ins.provider IS NOT NULL
AND ins.provider > 0
ORDER BY ins.date DESC
LIMIT 1;