使用Number作为标识符在两个日期之间获取数据

时间:2018-01-18 07:43:35

标签: sql sql-server

我正在尝试在MS SQL Server中进行SQL查询,我在其中设置了一个帐号进行搜索,它为我提供了两个日期范围之间的数据。

代码看起来像这样

select *
from transactions
where accountNo1 = '2005457846' transaction_date between '15-01-2018' and '18-01-2018'

显然我没有正确地做什么告诉我

  在transaction_date附近的

语法错误

2 个答案:

答案 0 :(得分:1)

您忘记在查询中添加AND。

select *
from transactions
where accountNo1 = '2005457846' and transaction_date between '15-01-2018' and '18-01-2018'

答案 1 :(得分:-1)

使用"和"也看日期格式

select * from transactions where accountNo1 ='2005457846' and transaction_date between '15-01-2018' and '18-01-2018'