为什么 COALESCE(date1,date2)
返回 Blob
(二进制)?两列都是 DATETIME
类型。
这是完整的 sql 查询:
SELECT COALESCE( last_modified, date_purchased )As LastModifiedOrPurchased
FROM Orders
ORDER BY COALESCE( last_modified, date_purchased )DESC
LIMIT 1;
我通常使用 SQL-Server 作为 rdbms,但需要编写一个同步工具。现在我正在尝试选择两个日期之一。如果 last_modified
为空,则应返回 date_purchased
。
但即使有多个记录的两个日期都不为空,查询也只会返回 Blob
。如何获得正确的最后日期?
编辑:在SQL-Fiddle它不能用 MySql 5.1.61 重现(我在 5.0.51 上)。
最佳答案
这可能是一个已修复的错误: bug-35662
[28 Mar 2008 22:44] Patrick Crews
Description:
COALESCE(date, date)
returns varbinary on 5.0.51a for Windows XP 32bit (only tested this flavor)
COALESCE(date,date)
returns date on Mac OS...
...
...[31 Mar 2008 17:41] Omer BarNir
The bug was fixed in 5.0.52 and was not observed when testing 5.0.56 - closing
关于mysql - COALESCE 两个日期返回二进制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13761960/