Subject Re: [IBO] FieldByName with table alias
Author Helen Borrie
At 12:48 AM 23-08-02 +0200, you wrote:
>Hi!
>
>select * from table customer
>left join table copyto on copyto.id=:copyto
>left join table secondcopy on secondcopy.id=:secondcopy

This syntax won't work.

select * from customer custalias
left join copyto ctalias
on custalias.parentkey = ctalias.childkey
left join secondcopy scalias
on scalias.someotherkey = [see ** below]
WHERE ctalias.id=:copyto
AND scalias.id=:secondcopy

Consult the manual to find the correct syntax for joins.

The purpose of JOIN criteria is to provide the links between the joined
tables. They have to be identifiers of columns that exist and can be
linked (same data type and size).
The WHERE clause is used for passing search criteria, including parameters
if you want parameterised queries.


>How can all fields be accessed via FieldByName?
>
>FieldByName('name') or FieldByName('secondcopy.name') won't
>work...

If copyto is the name of the query:

copyto.FieldByName('name').Value
or
copyto.FieldByName('name').AsString

Helen