DataSe := TADOQuery.Create(self); DataSe.ConnectionString:='Provider=OraOLEDB.Oracle.1;Password=pass;Persist Security Info=True;User ID=db;Data Source=oracle1'; DataSe.SQL.Clear; DataSe.SQL.Add('select count(t.id) as sj from table1 t where t.id in (select c.id from table2 c where c.typeid = ''9'') and t.time between to_date('''+DateTimeToStr(DateTimePicker1.DateTime)+''',''yyyy-mm-dd hh24:mi:ss'') and to_date('''+DateTimeToStr(DateTimePicker2.DateTime)+''',''yyyy-mm-dd hh24:mi:ss'') and t.memo like ''%深圳%'''); DataSe.Open; Edit1.Text := DataSe.FieldByName('sj').AsString; DataSe.Free;
上边代码在同一个数据库中不同表,可以正常统计数据. 问题: 现在在另一个数据库中统计数据,同样需要
Delphi(Pascal) code
t.id in (select c.id from table2 c where c.typeid = ''9'')