Board index » delphi » Query : Field Names with spaces ??

Query : Field Names with spaces ??

I am working on a database whose field names contain spaces. When I
run a query on a field name that has no spaces it works fine. When I
run a query on a field name with spaces it doesn't find the data. Some
examples of what I've tried are:

Select * from "Foo.db"
Where Managing Owner Surname = "Walsh"

This just gives 'Invalid use of keyword. Token: Owner. Line 2
Then I try with single or double quotes

Select * from "Foo.db"
Where "Managing Owner Surname" = "Walsh"

This one runs but doesn't find the data.
(Of course I'm searching for data that I know is there.)

Any help would be appreciated.
Thanks

~~~~~~~~~~~~~~~~~~~~~~~~~~~
Don Walsh
Dadyeen Studios
St. John's, Newfoundland.
(709) 579-6320 [fax (709) 579-7305]
http://www.nfld.com/~donwalsh
~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

Re:Query : Field Names with spaces ??


Quote
donwa...@nfld.com wrote:
> I am working on a database whose field names contain spaces. When I
> run a query on a field name that has no spaces it works fine. When I
> run a query on a field name with spaces it doesn't find the data. Some
> examples of what I've tried are:

> Select * from "Foo.db"
> Where Managing Owner Surname = "Walsh"

> This just gives 'Invalid use of keyword. Token: Owner. Line 2
> Then I try with single or double quotes

> Select * from "Foo.db"
> Where "Managing Owner Surname" = "Walsh"

> This one runs but doesn't find the data.
> (Of course I'm searching for data that I know is there.)

With Delphi1, I had to qualify the field or I got a "capability not
supported". Remembering that, I applied it to your problem and it
appears to work with either single or double quotes, if you do just
that:
        select * from foo
        where foo.'Managing Owner Surname'='Walsh'
One "bug" has been replaced by another. I prefered the old one, where
it didn't work as expected. But this one could mislead someone...

Happy programming.

Jasper

Other Threads