Page 1 of 1

Underlying Table & Field corresponding with Column

Posted: Wed 06 Jun 2012 20:46
by dadeishk
Is there a way to derive the underlying table and field for a given column name?

For Example:

SELECT Memberships.Description AS MembershipName, CustomerMemberships.Date as Enrolled, Customers.FirstName+' '+Customers.LastName As Person
FROM Memberships INNER JOIN
CustomerMemberships ON Memberships.MembershipID = CustomerMemberships.MembershipID INNER JOIN
Customers ON CustomerMemberships.CustomerID = Customers.CustomerID


Given the following column name "MembershipName"

Is there a method to derive "Description" as the underlying Field and "Memberships" as the underlying Table?

I realize the circumstances that where Table and field names could not be derived, such as the "Person" column which results from concatenated fields.

Re: Underlying Table & Field corresponding with Column

Posted: Mon 11 Jun 2012 13:06
by AlexP
Hello,

When you know the field alias, you can retrieve the real field name, the table alias and name in the following way:

Code: Select all

 TCRFieldDesc(UniQuery1.GetFieldDesc('MembershipName')).ActualName;  <-- the real field name
  TCRFieldDesc(UniQuery1.GetFieldDesc('MembershipName')).TableInfo.TableName; <-- the real table name 
  TCRFieldDesc(UniQuery1.GetFieldDesc('MembershipName')).TableInfo.TableAlias; <-- the table alias

Re: Underlying Table & Field corresponding with Column

Posted: Thu 14 Jun 2012 15:35
by dadeishk
Perfect. Thank you. :D

Re: Underlying Table & Field corresponding with Column

Posted: Thu 14 Jun 2012 16:16
by AlexP
hello,

Glad to see that the problem was solved. If you have any other questions, feel free to contact us.