How do you get MySQL to return the table names in the resultset when more than one table is in the select statement using ADO ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Noah Bawdy

    How do you get MySQL to return the table names in the resultset when more than one table is in the select statement using ADO ?

    This should be a <duh> but I can't find the answer.
    For example:

    SELECT Company_Default s.CompanyID, Company.Company ID
    FROM Company_Default s Left Join Company on Company_Default s.CompanyID =
    Company.Company ID
    Where Company.Company ID = 1
    And Company_Default s.CompanyID = 1

    This is over-simplified but it will give you the symptom.
    With Access, Microsoft SQL Server, Sybase and Oracle, the resultset will
    have the fields as Company.Company ID and Company_Default s.CompanyID.
    With MySQL both fields are returned as just CompanyID. How do I get MySQL to
    include the table names for identically named fields ?

    TIA

    Noah


  • Rich R

    #2
    Re: How do you get MySQL to return the table names in the resultset when more than one table is in the select statement using ADO ?


    "Noah Bawdy" <NoahBawdy@NoSp am.Com> wrote in message
    news:10t98385h8 936a7@corp.supe rnews.com...[color=blue]
    > This should be a <duh> but I can't find the answer.
    > For example:
    >
    > SELECT Company_Default s.CompanyID, Company.Company ID
    > FROM Company_Default s Left Join Company on Company_Default s.CompanyID =
    > Company.Company ID
    > Where Company.Company ID = 1
    > And Company_Default s.CompanyID = 1
    >
    > This is over-simplified but it will give you the symptom.
    > With Access, Microsoft SQL Server, Sybase and Oracle, the resultset will
    > have the fields as Company.Company ID and Company_Default s.CompanyID.
    > With MySQL both fields are returned as just CompanyID. How do I get MySQL[/color]
    to[color=blue]
    > include the table names for identically named fields ?
    >
    > TIA
    >
    > Noah
    >[/color]
    If you just want to rename the column headings, then:
    SELECT Company_Default s.CompanyID as 'Company_Defaul ts.CompanyID',
    Company.Company ID as 'Company.Compan yID'

    Notice the single quotes around the alias. These are necessary so as not to
    be confused with a fully qualified column name.

    Regards,
    Rich


    Comment

    Working...