Re:TQuery SQL question
On 17 Jan 1998 22:11:52 GMT, "Julian Sanchez" <jul...@w-bin.com> wrote:
[...]
Quote
>> SELECT *
>> FROM 'COMPANIES.DB'
>> LEFT OUTER JOIN 'CATEGORIES.DB'
>> ON (COMPANIES.IDCOMPANY = CODESCAT.IDCOMPANY)
>> LEFT OUTER JOIN 'CODESCAT.DB'
>> ON (CATEGORIES.IDCATEgory = CODESCAT.IDCATEgory)
>> WHERE (COMPANIES.IDCOMPANY = :A)
>> ORDER BY CATEGORIES.TEXT;
>> Note that when using collation names for tables, the default is the table
>> name as specified in the FROM clause. Ergo, you do not need to explicitly
>> specify the full table name for a collation name. Functionally the same,
>> but shortens the statement some.
>mmm I get a "EDBEngineError with message 'Invalid field name. IDCOMPANY"
>I have checked for typos but everything is just the way is supposed to be.
>What could be wrong?
I stand corrected on this. Here are some clarifications.
If the table name is not a quoted string, the table name is the default
implicit collation name. An explicit collation name the same as the table
name need not be specified in the FROM clause and the table name can prefix
column names in other parts of the statement.
SELECT *
FROM CUSTOMER
LEFT OUTER JOIN ORDERS
ON (CUSTOMER.CUSTNO = ORDERS.CUSTNO)
If the table name is a quoted string, you need to do one of the following:
1. Prefix column names with the exact quoted string used for the table in
the FROM clause.
SELECT *
FROM "CUSTOMER.DB"
LEFT OUTER JOIN "ORDERS.DB"
ON ("CUSTOMER.DB".CUSTNO = "ORDERS.DB".CUSTNO)
2. Use the full table name as a collation name in the FROM clause (and
prefix all column references with the same collation name).
SELECT *
FROM "CUSTOMER.DB" CUSTOMER
LEFT OUTER JOIN "ORDERS.DB" ORDERS
ON (CUSTOMER.CUSTNO = ORDERS.CUSTNO)
3. Use a distinct token as a collation name in the FROM clause (and prefix
all column references with the same collation name).
SELECT *
FROM "CUSTOMER.DB" C
LEFT OUTER JOIN "ORDERS.DB" O
ON (C.CUSTNO = O.CUSTNO)
**************************************************************************
Steve Koterski
Borland International, Inc.
http://www.borland.com/delphi
(Remove the "SPICEDHAM2" from the address. Death to spam-bots!)