为什么将 LIKE 与 TIMESTAMPS 一起使用在 DB2 中不起作用

编程入门 行业动态 更新时间:2024-10-27 22:22:12
本文介绍了为什么将 LIKE 与 TIMESTAMPS 一起使用在 DB2 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在 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 中不起作用

本文发布于:2023-11-24 11:07:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624957.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中不   TIMESTAMPS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!