Retrieve correct table alias
Posted: Fri 08 Aug 2008 10:34
Hi, is there a way to retrieve the correct alias of tables specified in the TMsQuery.SQL property? I tried with FieldDesc := TCRFieldDesc(msQuery1.GetFieldDesc(msQuery1.Fields));
but it doesn't seem to work since with a (stupid) sql like
select cust1.customerID, cust2.companyname
from customers cust1 inner join customers cust2 on cust1.customerid = cust2.customerid
it returns two times the same alias:
Origin: customers.customerID
Fieldname : customerID
TableAlias: cust2
Origin: customers.companyname
Fieldname : companyname
TableAlias: cust2
Obviously for customerID the tableAlias should be cust1. The problem appears having the same table two or more times with different aliases.
Is there another way to retrieve the alias or can you fix this issue?
Best regards
Toni Santa
but it doesn't seem to work since with a (stupid) sql like
select cust1.customerID, cust2.companyname
from customers cust1 inner join customers cust2 on cust1.customerid = cust2.customerid
it returns two times the same alias:
Origin: customers.customerID
Fieldname : customerID
TableAlias: cust2
Origin: customers.companyname
Fieldname : companyname
TableAlias: cust2
Obviously for customerID the tableAlias should be cust1. The problem appears having the same table two or more times with different aliases.
Is there another way to retrieve the alias or can you fix this issue?
Best regards
Toni Santa