I have 4 fields that I need ->
- USERID
- LOCATION
- REPORT_MGR_USERID (reporting manager user ID)
- Manager Location (this is not actually stored)
To get the 4th one, I need to build it using SQL. I can do this via the “USERID” and “LOCATION” fields.
Here is my attempt. I am running a query within Access 2007, via a linked DB2 table.
SELECT DISTINCT employee_table.LOCATION, employee_table.USERID, employee_table.REPORT_MGR_USERID, manager_location
FROM employee_table main
JOIN employee_table (SELECT DISTINCT employee_table.LOCATION FROM employee_table AS sub WHERE sub.USERID = main.REPORT_MGR_USERID) manager_location
When I run it, it’s giving me this error ->
Syntax error in FROM clause
and then highlights the JOIN keyword.
This looks correct from everything I’ve looked at….
EDIT:
Thanks to David W, this is the working version for future reference ->
SELECT DISTINCT main.LOCATION, main.USERID, main.REPORT_MGR_USERID, manager_data.LOCATION
FROM employee_table main
INNER JOIN employee_table manager_data
ON main.REPORT_MGR_USERID=manager_data.USERID
You are specifying both a table name
employee_tableand a subselect(SELECT DISTINCT....)in the first JOIN clause. And there’s no ON condition, although that may be what you want?The specification of
employee_tablein that JOIN might just be a typo, since you’ve provided an alias for the subselect…Edit The light bulb just went on and I understand what the OP wants. Here we go: