greetings,
I am running Delphi 6 with Zeoslib 6.1.5-stable and Mysql.
I have a TZQuery component on my form and have added SQL code
to the SQL property of the TZQuery component.
Normally I reference a field by using someting like:
MyQuery.fieldbyname('name').asstring
Well, I gone and used a join in my SQL code and don't know how to
reference a field ?
ie, select dealer.dnum, dealer.name,mixtemp.name from dealer left join
mixtemp on dealer.dnum = mixtemp.dnum
can't reference fields like
MyQuery.fieldbyname('dealer.dnum').asstring
as that gives a big error.
How do you do it ?
thanks,
D
Accessing Join fields
Moderators: gto, cipto_kh, EgonHugeist
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Use an alias for your field names like this:
Then you can do
Mark
Code: Select all
select dealer.dnum d_dnum, dealer.name d_name,mixtemp.name m_name from dealer left join mixtemp on dealer.dnum = mixtemp.dnum
Code: Select all
MyQuery.fieldbyname('d_dnum').asstring
I use joined tables avery day and I always just state the name of the field after the word "Select". In your example:
It has always worked OK for me. Post here if the tip os OK or not!
Code: Select all
MyQuery.fieldbyname('dnum').asstring;