我在 DB2 中使用 LIKE 结构时遇到问题:例如:
i have problem using LIKE structure in DB2: for example:
select * from TEST where TIME LIKE '2012-03-04-%'仅供参考.- TIME 是 TIMESTAMP 数据类型.
FYI. - TIME is TIMESTAMP data type.
为什么使用 LIKE 和 TIMESTAMPS 不起作用?
why using LIKE with TIMESTAMPS do not work?
附加信息:我想从用户在 select 语句中提供的一天中提取数据.
Additional info: i want to extract data from one single day provided by user in select statement.
推荐答案只是扩展@mortb 的答案,我会使用 BETWEEN 或
Just expanding on @mortb's answer, I'd either use BETWEEN or
WHERE time >= '2012-03-04' AND time < '2012-03-05'使用 BETWEEN 的优势或使用 casts 和 LIKE 的比较意味着如果在 time 上有索引 由于强制转换,它无法使用.
The advantage of using BETWEEN or a comparison that using casts and LIKE will mean that if there is an index on time it wouldn't be able to be used due to the casting.
更多推荐
为什么将 LIKE 与 TIMESTAMPS 一起使用在 DB2 中不起作用
发布评论