我曾尝试使用dbeaver查询SQL Server,但我不知道出了什么问题。我的系统是64位的Ubuntu 17和dbeaver 4.1.2。
我可以连接到数据库,浏览表格,我做的大多数查询都是成功的。
但是当我尝试查询datetime列时,我得到了这些:
使用>=
:
select date_field from mydb where date_field >= '2018-01-01'; => ok, shows results
select date_field from mydb where date_field >= '2018-01'; => Ok, shows results
select date_field from mydb where date_field >= '2018'; => Ok, shows results
与=
:
select date_field from mydb where date_field = '2018-01-01'; => query runs w/o errors, but shows nothing
select date_field from mydb where date_field = '2018-01-01 00:00:00'; => query runs w/o errors, but shows nothing
select date_field from mydb where date_field = '2018-01-01 any:time:sec'; => query runs w/o errors, but shows nothing, even I copy and paste full date from '>=' query
使用LIKE
:
select date_field from mydb where date_field like '2018-01-01%'; => query runs w/o errors, but shows nothing
select date_field from mydb where date_field like '%2018-01-01%'; => query runs w/o errors, but shows nothing
select date_field from mydb where date_field like '2018-01%'; => query runs w/o errors, but shows nothing
select date_field from mydb where date_field like '%2018-01%'; => query runs w/o errors, but shows nothing
select date_field from mydb where date_field like '2018%'; => query runs w/o errors, but shows nothing
select date_field from mydb where date_field like '%2018%'; => OK, shows results
我还没有尝试过其他语句(在...之间)。但任何人都已经面临过这个问题
谢谢!
我试图用LIKE语句查询DATETIME列。 @MJH提醒我,这个语句用于比较字符串。我一直在这样做,因为我曾经在MySQL上查询并且没有问题。谢谢@MJH!
经过@MJH建议指导的一些研究后,我尝试了以下查询:
select date_field from mydb where cast(date_field as DATE) = '2018-01-01';
我得到了理想的结果!
我将问DBeaver开发人员是否存在可能的错误。
非常感谢!