Home > Archive > Clarion > June 2006 > Aliasing a Column Name in Topspeed ODBC SQL
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Aliasing a Column Name in Topspeed ODBC SQL
|
|
| grahamL 2006-06-17, 7:56 am |
| I'm trying to export data from a topspeed dataset using the Topspeed
ODBC driver (V5.0) from Softvelocity using Visual Basic 6.
I have a main clients table which has two columns, which both link to
the same column in a users table by a numeric code. I would like to
retrieve the corresponding initials for both user Columns.
A (cut-down) MS SQL query looks like this...
SELECT CLIENT.C_CODE, USERS.INITIALS, USERS2.INITIALS AS User2Code
FROM (CLIENT LEFT JOIN USERS ON CLIENT.USERCODE = USERS.U_CODE) LEFT
JOIN USERS AS USERS2 ON CLIENT.U2_CODE = USERS2.U_CODE;
'AS' is used to give USERS2.INITIALS an Alias of User2Code, but looking
at the TopSpeed ODBC help, it is not clear if there is a supported
equivalent, but then neither is it clear how to use 2 or more outer
joins. Any help will be most welcome.
Thanks
Graham
| |
| grahamL 2006-06-17, 7:56 am |
| A BIG thanks to Robert at Softvelocity support for pointing me in the
right direction. The trick is to put each of the LEFT OUTER JOINS in an
object and then alias the duplicated field (in my case INITIALS) like
this...
SELECT c.C_CODE, u.INITIALS, uu.INITIALS u2initials
FROM
{obj1 CLIENT c LEFT OUTER JOIN USER u ON c.USERCODE = u.U_CODE},
{obj2 CLIENT cc LEFT OUTER JOIN USER uu ON cc.U2_CODE = uu.U_CODE}
WHERE c.C_CODE = cc.C_CODE
Graham
|
|
|
|
|