Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query -- Identical field names causing problems

Status
Not open for further replies.

jwruble

Programmer
May 29, 2002
16
0
0
US
I'm creating a query for a report that displays information about different surveys of a site. Important info includes when each survey was completed and who did the survey. In the database, the "who" is stored as a number, which can then be linked to an employee table to see their name and title.

In the query, I just link the number from the main table to the number in the employee table, and it all works fine for the first survey info. However, when I add the table again so it can link the second surveyor, I get an error message that says, "The specified field [LastName]could refer to more than one table listed in the FROM clause of your SQL statement".

Do I need to somehow rename the second [LastName] field in my query, or is there some way around this problem?
 
you need to show the table name followed by a dot and then the field name

PaulF
 
PaulF is right. The other option is that in your query source you could set an alias for the field:

Whofrom1: table1.[who]
Whofrom2: table2.[who]

first select the field as normal, and then at the start of the name of the field you want an alias for, put the alias name and a : - leave the rest as it is.

that way you can refer to them without using the table name. Might be clearer depending on you usage and naming conventions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top