Skip navigation
Currently Being Moderated

Alias a field name in a join query

Jun 17, 2013 12:17 PM

I have a database with spaces in the field names (not my fault).


I am having a problem with the query because one of the fileds I am joining on has a space in its name. See bolded text.



FROM employee_passwords

INNER JOIN employee_general_info

ON employee_passwords.Employee_ID=employees.[Employee ID]

WHERE username = '#username#' AND password = '#password#'  


So I get this error message


Error Executing Database Query.


[Macromedia][SQLServer JDBC Driver][SQLServer]Invalid object name 'employees.Employee ID'.



Is there a way to alias the employees.[Employee ID] field?

  • Currently Being Moderated
    Jun 17, 2013 12:32 PM   in reply to weezerboy

    The error is probably from the SELECT * -  try listing all of the fields individually, including the [Employee ID] field.  You can give it a new name to appear in the query results by aliasing it:

         SELECT [employee ID] AS EmployeeID

    but within the query itself you have to use the [Employee ID] syntax.


    Mark as:
  • Currently Being Moderated
    Jun 17, 2013 2:56 PM   in reply to weezerboy

    Should be


    ON employee_passwords.Employee_ID=employee_general_info.[Employee ID]

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points