You left out a close parenthesis. Change this ...
ON ([Branch Mgmt].[Left 3 of address] = left([SalesPage Offices w/CRD].ADDRESS_LINE_1,3)
to this ...
ON ([Branch Mgmt].[Left 3 of address] = left([SalesPage Offices w/CRD].ADDRESS_LINE_1,3))
문제
Alright, I am attempting to use a basic left() function with a MS Access query, in order to create an inner join between two tables. The two columns that will be joined contain the first 3 character of a given street address.
I have attempted to use the function as shown:
I simply want to take the first 3 characters (from the left obviously) of this column, and join it to the "Left 3 of adress" column in my Branch Management sheet. Every time I attempt to run this query however, I get a syntax error. The left function is pretty straightforward in almost every language/RDBMS, what am I doing wrong?
EDIT: here is a screen shot of the error: The error is wonderfully vague.
해결책
You left out a close parenthesis. Change this ...
ON ([Branch Mgmt].[Left 3 of address] = left([SalesPage Offices w/CRD].ADDRESS_LINE_1,3)
to this ...
ON ([Branch Mgmt].[Left 3 of address] = left([SalesPage Offices w/CRD].ADDRESS_LINE_1,3))
다른 팁
I don't think you can use the LEFT()
function in your join statement. Instead run a sub query to get the field you want and then link them together. Something like the following:
SELECT M.TRADE_FIRM, M.POSTAL_CODE_1, M.ADDRESS_LINE_1,
M.OFFICE_ID, M.STATE_PROVINCE, M.CITY, B.*
FROM
(
SELECT S.*, LEFT(S.ADDRESS_LINE_1, 3) AS Left3Addr
FROM [SalesPage Offices w/CRD] AS S
) AS M
INNER JOIN [Branch Mgmt] AS B ON B.[Left 3 of address] = M.Left3Addr
AND B.State = M.State
AND B.City = M.City
WHERE M.TRADE_FIRM = 'WHATEVER'