为什么在DB2中使用LIKE和TIMESTAMPS不起作用 [英] why using LIKE with TIMESTAMPS do not work in DB2

查看:132
本文介绍了为什么在DB2中使用LIKE和TIMESTAMPS不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 DB2 中使用 LIKE 结构时遇到问题:
例如:

i have problem using LIKE structure in DB2: for example:

select * from TEST where TIME LIKE '2012-03-04-%'

FYI。 - TIME TIMESTAMP 的资料类型。

FYI. - TIME is TIMESTAMP data type.

LIKE TIMESTAMPS 不起作用?

:我想从select语句中用户提供的一天中提取数据。

Additional info: i want to extract data from one single day provided by user in select statement.

推荐答案

请使用 BETWEEN

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.

这篇关于为什么在DB2中使用LIKE和TIMESTAMPS不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆