S
super_duck
Unregistered / Unconfirmed
GUEST, unregistred user!
各位大哥,我的sql语句哪里出错?在运行程序前已将两个表建好了的,
var
sql1,sql2,sql3,sql4,sql5,sql6,sql7,sql8,sql9,sql10,sql11,sql12:string;
sql201,sql202:string;
begin
query1.close;
query1.SQL.Clear;
query1.SQL.Add('drop table dx');
query1.ExecSQL;
query1.open;
sql201:='create table dx (testtime,vn,marktype) as select max(testtime),vn,marktype from app_info_bck ';
sql202:='group by vn,marktype';
query1.close;
query1.SQL.Clear;
query1.SQL.Add(sql201+sql202);
query1.ExecSQL;
query1.open;
query1.close;
query1.SQL.Clear;
query1.SQL.Add('drop table dx_t');
query1.ExecSQL;
query1.open;
sql1:='create table dx_t (vn,testtime,vehiclemaster,testarea,cartype,';
sql2:='purchasedate,trademark,testtype,marktype) as select ';
sql3:='dx.vn,dx.testtime,vehiclemaster,dm_testarea.hz,dm_cartype.hz,';
sql4:='purchasedate,trademark,dm_testtype.hz,dm_marktype.hz from dx,app_info_bck,';
sql5:='dm_cartype,dm_testarea,dm_marktype,dm_testtype ';
sql6:='where app_info_bck.testtype=dm_testtype.dm ';
sql7:='and app_info_bck.testarea=dm_testarea.dm ';
sql8:='and app_info_bck.cartype=dm_cartype.dm ';
sql9:='and dx.marktype=dm_marktype.dm ';
sql10:='and dx.vn=app_info_bck.vn ';
sql11:='and dx.testtime=app_info_bck.testtime ';
sql12:='and dx.marktype=app_info_bck.marktype';
query1.close;
query1.SQL.Clear;
query1.SQL.Add(sql1+sql2+sql3+sql4+sql5+sql6+sql7+sql8+sql9+sql10+sql11+sql12);
query1.ExecSQL;
query1.open;
query1.close;
query1.SQL.Clear;
query1.SQL.Add('select * from dx_t');
query1.ExecSQL;
query1.Open;
query1.Active:=true;
showmessage('转换成功!');
end;
var
sql1,sql2,sql3,sql4,sql5,sql6,sql7,sql8,sql9,sql10,sql11,sql12:string;
sql201,sql202:string;
begin
query1.close;
query1.SQL.Clear;
query1.SQL.Add('drop table dx');
query1.ExecSQL;
query1.open;
sql201:='create table dx (testtime,vn,marktype) as select max(testtime),vn,marktype from app_info_bck ';
sql202:='group by vn,marktype';
query1.close;
query1.SQL.Clear;
query1.SQL.Add(sql201+sql202);
query1.ExecSQL;
query1.open;
query1.close;
query1.SQL.Clear;
query1.SQL.Add('drop table dx_t');
query1.ExecSQL;
query1.open;
sql1:='create table dx_t (vn,testtime,vehiclemaster,testarea,cartype,';
sql2:='purchasedate,trademark,testtype,marktype) as select ';
sql3:='dx.vn,dx.testtime,vehiclemaster,dm_testarea.hz,dm_cartype.hz,';
sql4:='purchasedate,trademark,dm_testtype.hz,dm_marktype.hz from dx,app_info_bck,';
sql5:='dm_cartype,dm_testarea,dm_marktype,dm_testtype ';
sql6:='where app_info_bck.testtype=dm_testtype.dm ';
sql7:='and app_info_bck.testarea=dm_testarea.dm ';
sql8:='and app_info_bck.cartype=dm_cartype.dm ';
sql9:='and dx.marktype=dm_marktype.dm ';
sql10:='and dx.vn=app_info_bck.vn ';
sql11:='and dx.testtime=app_info_bck.testtime ';
sql12:='and dx.marktype=app_info_bck.marktype';
query1.close;
query1.SQL.Clear;
query1.SQL.Add(sql1+sql2+sql3+sql4+sql5+sql6+sql7+sql8+sql9+sql10+sql11+sql12);
query1.ExecSQL;
query1.open;
query1.close;
query1.SQL.Clear;
query1.SQL.Add('select * from dx_t');
query1.ExecSQL;
query1.Open;
query1.Active:=true;
showmessage('转换成功!');
end;