这是Oracle的写法select * from jiben_account
where strtodate(kaihui_date) between t1.date and t2.date
union
select * from yiban_account
where strtodate(kaihui_date) between t1.date and t2.date
union
select * from temp_account
where strtodate(kaihui_date) between t1.date and t2.date
union
select * from zuanyong_account
where strtodate(kaihui_date) between t1.date and t2.date
union
select * from qita_account
where strtodate(kaihui_date) between t1.date and t2.date
where strtodate(kaihui_date) between t1.date and t2.date
union
select * from yiban_account
where strtodate(kaihui_date) between t1.date and t2.date
union
select * from temp_account
where strtodate(kaihui_date) between t1.date and t2.date
union
select * from zuanyong_account
where strtodate(kaihui_date) between t1.date and t2.date
union
select * from qita_account
where strtodate(kaihui_date) between t1.date and t2.date
invalid use of keyword
token:date
怎么回事?
Query2.params[0].asdate:=t1.date;
Query2.params[1].asdate:=StrToDate(kaihui_date);
Query2.params[2].asdate:=t2.date;
Query2.params[3].asdate:=StrToDate(kaihui_date);where前应该有一个空格,用单引号引起来的被认为是sql字符串,数据库怎么会知道strtodate(), t1.date, t2.date是什么意思呢?另外我把判断语句掉了个个,习惯把字段写在前面,要比较的数值写在后面。
select * from table1 where kaihu_Date between date1 and date2 union
select * from table2 where kaihu_date between date1 and date2 union
.....
select * from table5 where kaihu_date between date1 and date2
where前加空格也不对,我试过了,
继续报错
invalid use of keyword
token:date
怎么回事?
where strtodate(kaihui_date) between t1.date and t2.date
union
select * from yiban_account
where strtodate(kaihui_date) between t1.date and t2.date
union all
select * from temp_account
where strtodate(kaihui_date) between t1.date and t2.date
union all
select * from zuanyong_account
where strtodate(kaihui_date) between t1.date and t2.date
union all
select * from qita_account
where strtodate(kaihui_date) between t1.date and t2.date
if (checkbox1.bchecked=True)or (checkbox2.bchecked=true) then
試一下.
add('select * from jiben_account,yiban_account,temp_account,zuanyong_account,qita_account');add(' where to_date(''yyyy-MM-dd'','+DateToStr(t1.date)+')<='+'to_date(''yyyy-MM-dd'','+kaihui_date+') and '+'to_date(''yyyy-MM-dd'','+DateToStr(t2.date)+')>='+'to_date(''yyyy-MM-dd'','+kaihui_date+')') ;
**************************************************************
注意:
Sql 语句并不认识你写的t2.date 和t1.date是变量,他认为那是数据库中的字段,他将t2认为表名,将data认为是t2表的字段,所以报错!!
你应该这样写:
'where kaihui_date<='''+datetostr(t2.date)+''' and kaihui_date>='''+datetostr(t1.date)+'''') ;**************************************************************
好啦,我不多说啦!!
去试吧!!
type mismatch in expression
这样才可以的!
select * from jiben_account
where to_date(kaihui_date) between :t1 and :t2
union
select * from yiban_account
where to_date(kaihui_date) between :t1 and :t2
union
select * from temp_account
where to_date(kaihui_date) between :t1 and :t2
union
select * from zuanyong_account
where to_date(kaihui_date) between :t1 and :t2
union
select * from qita_account
where to_date(kaihui_date) between :t1 and :t2Query.ParamByName('t1').AsDate := T1.Date;
Query.ParamByName('t2').AsDate := T2.Date;
Query.Open;另外,你的kaihui_date是什么格式的,是否跟你数据库中的日期格式相同,不同的话要改,如To_Date(kaihui_date,'yy.mm.dd')