delphibdetquery

delphi "Invalid use of keyword" in TQuery


I'm trying to populate a TDBGrid with the results of the following TQuery against the file Journal.db:

select * from Journal
where  Journal.where = "RainPump"

I've tried both Journal."Where" and Journal.[Where] to no avail.

I've also tried: select Journal.[Where] as "Location" with the same result.

Journal.db is a file created by a third party and I am unable to change the field names.

The problem is that the field I'm interested in is called 'where' and understandably causes the above error. How do I reference this field without causing the BDE (presumably) to explode?


Solution

  • You can insert the resultset into a new table with "values" (specifying no column names) where you have given your own column names in the new table and then do a select from that table, Using a TQuery, something like:

    Query1.sql.clear;
    query1,sql.add('Insert into newtable values (select * from Journal);');
    query1.sql.add('Select * from newtable where newcolumn = "Rainpump";');
    query1.open;