2 Fields with Same Name

Results 1 to 3 of 3

Thread: 2 Fields with Same Name

  1. #1
    Join Date
    Dec 1969
    Posts
    109

    Default 2 Fields with Same Name

    I want to query 3 tables from an Access database and display the results. The problem is that 2 of the tables have a field called Name and I want to display both values but my ASP skips the first Name value and only displays the 2nd.<BR><BR>e.g.<BR><BR>Select a.Name, b.Name<BR>From Contacts As a, Functions As b, Contacts_Functions As c<BR>Where a.Contact_ID = c.Contact_ID<BR>And b.Function_ID = c.Function_ID<BR><BR>When I try to specify which "Name" I want (e.g. rs("a.Name") or rs("b.Name")) I get an unrecognized ordinal reference error. Any suggestions? (besides just renaming one of the fields)<BR><BR><BR>Oliver

  2. #2
    Mike F. Guest

    Default RE: 2 Fields with Same Name

    The syntax I am more familiar with would be<BR><BR>Select a.Name AS Name_from_A, b.Name as Name_from_B<BR>From Contacts a, Functions b, Contacts_Functions c<BR>Where a.Contact_ID = c.Contact_ID<BR>And b.Function_ID = c.Function_ID<BR><BR>The "AS" is used to rename the field and no "AS" is used for the table alias.<BR><BR>If you open a recordset with the above you should be able to get myrs("Name_from_A") and myrs("Name_from_B") to return the correct values.<BR><BR>Mike

  3. #3
    Join Date
    Dec 1969
    Posts
    109

    Default RE: 2 Fields with Same Name

    Thanks Mike! I completely forgot about aliasing the fieldnames in the sql statement. Great job!<BR><BR><BR>Oliver

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •