形如select * from table where riqi between ‘2002-12-24-11-08‘and '2002-12-24-11-20'and otherfield='34'
其中数据库中有两条纪录在其中。
其中一个是 2002-12-24-11-20
另一个是 2002-12-24-11-08
可是我用此SQL语句输出却只显示一条纪录符合条件,这是怎么回事?
另外我想用一个变量来代表 2002-12-24-11-20和2002-12-24-11-08
每次查询只要改变变量的内容就能查询
不用往SQL语句中写具体内容,怎么做呢
其中数据库中有两条纪录在其中。
其中一个是 2002-12-24-11-20
另一个是 2002-12-24-11-08
可是我用此SQL语句输出却只显示一条纪录符合条件,这是怎么回事?
另外我想用一个变量来代表 2002-12-24-11-20和2002-12-24-11-08
每次查询只要改变变量的内容就能查询
不用往SQL语句中写具体内容,怎么做呢
strSQL="Select * From Table Where riqi Between '";
strSQL+=strTimeA1;
strSQL+="' And '";
strSQL+=strTimeA2;
strSQL+=" And otherfield='34'";
strSQL="Select * From Table Where riqi Between '";
strSQL+=strTimeA1;
strSQL+="' And '";
strSQL+=strTimeA2;
strSQL+="' And otherfield='34'";
select * from table where riqi between cast('2002-.. as datetime) and cast('2002.....' as datetime) and otherfield='34'