I'm having (i think) a syntax Referencing problem when trying to run a query on 1 table and 1 existing tquery.
The problem is I want to run the tquery linking an ordinary mytable.db to a query I've already created using a TQuery.
Example:
//**** THE FIRST QUERY ******
strSQL := TStringList.Create;
with strSQL do
begin
Add('select *');
Add(Format('FROM "%s",[DataPath+'MYTABLE1.DB']));
end;
tquery1.SQL.Clear;
tquery1.SQL.Assign(strSQL);
tquery1.Open;
//**** THE SECOND QUERY ******
strSQL := TStringList.Create;
with strSQL do
begin
Add('Select <LIST OF FIELDS ETC>)');
Add(Format('FROM "%s","%s"',[DataPath+'MYTABLE2.DB','tquery1']));
Add('WHERE <CONDITION THAT MATCHES THEM>');
The first query does some formatting, so i am able to link the two together.
The problem I am having is that the second query finds MYTABLE2.DB no problem, but cannot find tquery1, it says table not found, which I know it wont find because it's in memory and not a physical table.
So my question is how can i reference the tquery inside an sql FROM statement.
Any help would be great.
Thanks
Glyn
The problem is I want to run the tquery linking an ordinary mytable.db to a query I've already created using a TQuery.
Example:
//**** THE FIRST QUERY ******
strSQL := TStringList.Create;
with strSQL do
begin
Add('select *');
Add(Format('FROM "%s",[DataPath+'MYTABLE1.DB']));
end;
tquery1.SQL.Clear;
tquery1.SQL.Assign(strSQL);
tquery1.Open;
//**** THE SECOND QUERY ******
strSQL := TStringList.Create;
with strSQL do
begin
Add('Select <LIST OF FIELDS ETC>)');
Add(Format('FROM "%s","%s"',[DataPath+'MYTABLE2.DB','tquery1']));
Add('WHERE <CONDITION THAT MATCHES THEM>');
The first query does some formatting, so i am able to link the two together.
The problem I am having is that the second query finds MYTABLE2.DB no problem, but cannot find tquery1, it says table not found, which I know it wont find because it's in memory and not a physical table.
So my question is how can i reference the tquery inside an sql FROM statement.
Any help would be great.
Thanks
Glyn