I'm trying to do some join operations in sql access but I keep on getting the join operation error. At first it was just the JOIN alone, but then I realized I had to add the INNER which I did but it didn't resolve the error.
Code below:
SELECT Formula.*, Ingred.[Europe Ban]
FROM [Ingred]
INNER JOIN Ingred ON Formula.[Ingredient] = Ingred.Ingredients;
Presumably, you want Formula in the FROM clause, not Ingred twice:
SELECT Formula.*, Ingred.[Europe Ban]
FROM Formula INNER JOIN
Ingred
ON Formula.[Ingredient] = Ingred.Ingredients;
The query works pretty fine, I can view result as a table and sql code on his own without any problem. However then I try to press query design button, it crashed without saying why.
My code is pretty simple, after I added one more left join out of A subquery such error started to appear. This way last left join definitely cause the problem. Tried to join without using subquery but I get problem saying about ambiguous outer join. I'm newbie with access but I heard about several bugs in that program, any suggestion how to fix?
This problem query:
select A.*,targetresp.*
from (
SELECT *
FROM target INNER JOIN ((source INNER JOIN InstanceList
ON source.INFO_SYSTEM_TYPE_CD = InstanceList.INFO_SYSTEM_TYPE_CD)
INNER JOIN (N_table_transform INNER JOIN S2T
ON N_table_transform.N_table = S2T.N_table)
ON source.ID = S2T.source_id)
ON target.id = S2T.target_id ) as A
left join targetresp
on a.target_TableName = targetresp.tablename;
SELECT InstanceList.*
FROM
N_table_transform
INNER JOIN (((S2T INNER JOIN target
ON S2T.target_id = target.Id)
LEFT JOIN targetresp ON target.target_TableName = targetresp.target_TableName)
INNER JOIN (InstanceList
INNER JOIN source ON InstanceList.INFO_SYSTEM_TYPE_CD = source.INFO_SYSTEM_TYPE_CD)
ON S2T.source_id = source.Id)
ON N_table_transform.N_table = S2T.N_table;
I just use the access 2013 designer and build the query.
On the bottom switch between SQL and DESIGNER
I'm trying to make an UPDATE query (using Access 2013) that calculates a value based on values stored in two separate linked tables. Here is the code I'm using:
UPDATE tblCreatures
INNER JOIN tblRole ON tblCreatures.Role = tblRole.RoleName
INNER JOIN tblRank ON tblCreatures.Rank = tblRank.RankName
SET tblCreatures.HP = ((tblRole.Level_0_HP + (tblCreatures.NominalLevel * tblRole.BonusHP)) * tblRank.HP_Multiplier);
This gives me a syntax error, saying
Syntax error (missing operator) in query expression "tblCreatures.Role = tblRole.RoleName INNER JOIN tblRank ON tblCreatures.Rank = tblRank.RankNam"
(and yes, it cuts off at RankNam, not RankName)
Testing things out, if I remove one of the inner joins (and thus all references to that table) then the update query works just fine, but if I put the other inner join back in, I continuously get this same syntax error. I don't understand why... I should be able to put two inner joins next to each other, shouldn't I?
Access SQL requires parentheses when a query contains multiple JOINs. If you build the query in Access' query designer it will look like this (reformatted for clarity):
UPDATE
(
tblCreatures
INNER JOIN
tblRole
ON tblCreatures.Role = tblRole.RoleName
)
INNER JOIN
tblRank
ON tblCreatures.Rank = tblRank.RankName
SET tblCreatures.HP = ((tblRole.Level_0_HP + (tblCreatures.NominalLevel * tblRole.BonusHP)) * tblRank.HP_Multiplier);
I am getting a Syntax Error in FROM Clause dialog box when I try to run the following query in MS-Access 2010:
SELECT
Contact_addresses.AddressID,
Contact_addresses.ContactID,
Contact_addresses.Address1,
Contact_addresses.Address2,
Contact_addresses.City,
Contact_addresses.State,
Contact_addresses.Zip,
Owner_Operator.FIRM_NAME,
Official_Correspondent.FIRST_NAME,
Official_Correspondent.LAST_NAME,
Official_Correspondent.SUBACCOUNT_COMPANY_NAME,
Official_Correspondent.PHONE_NUMBER
FROM Contact_addresses
(
LEFT JOIN
(SELECT
Owner_Operator.CONTACT_ID,
Owner_Operator.FIRM_NAME
FROM Owner_Operator)
ON Contact_addresses.ContactID=Owner_Operator.CONTACT_ID
)
LEFT JOIN
(SELECT
Official_Correspondent.CONTACT_ID,
Official_Correspondent.FIRST_NAME,
Official_Correspondent.LAST_NAME,
Official_Correspondent.SUBACCOUNT_COMPANY_NAME,
Official_Correspondent.PHONE_NUMBER
FROM Official_Correspondent)
ON Contact_addresses.ContactID=Official_Correspondent.CONTACT_ID
;
When I dismiss the dialog box, access highlights the ( after FROM Contact_addresses.
I know that I need parentheses with multiple nested joins in Access, but can someone please explain the concepts of how this works, in addition to showing how to fix whatever the problem is?
The relevant aspects of the schema of the underlying tables should be clear from the SQL SELECT statements.
I think this should work, but I lack access to test. General syntax to hold to
From table
left join (statement) alias
on table.col = alias.col
left join ...
Altering your statement to this:
FROM Contact_addresses
LEFT JOIN
(SELECT
Owner_Operator.CONTACT_ID,
Owner_Operator.FIRM_NAME
FROM Owner_Operator) Owner_Operator
ON Contact_addresses.ContactID=Owner_Operator.CONTACT_ID
LEFT JOIN
(SELECT
Official_Correspondent.CONTACT_ID,
Official_Correspondent.FIRST_NAME,
Official_Correspondent.LAST_NAME,
Official_Correspondent.SUBACCOUNT_COMPANY_NAME,
Official_Correspondent.PHONE_NUMBER
FROM Official_Correspondent) Official_Correspondent
ON Contact_addresses.ContactID=Official_Correspondent.CONTACT_ID
;
I've added the table alias to match what you call it in your join and I removed the offending set of brackets.
The problem was in the location of the opening brackets ((. They need to be immediately after the first FROM. Here is what works:
SELECT Contact_addresses.AddressID, Contact_addresses.ContactID, Contact_addresses.Address1, Contact_addresses.Address2, Contact_addresses.City, Contact_addresses.State, Contact_addresses.Zip, Owner_Operator.FIRM_NAME, Official_Correspondent.FIRST_NAME, Official_Correspondent.LAST_NAME, Official_Correspondent.SUBACCOUNT_COMPANY_NAME, Official_Correspondent.PHONE_NUMBER
FROM ((Contact_addresses
LEFT JOIN
(SELECT
Owner_Operator.CONTACT_ID,
Owner_Operator.FIRM_NAME
FROM Owner_Operator) AS Owner_Operator
ON Contact_addresses.ContactID=Owner_Operator.CONTACT_ID
)
LEFT JOIN
(SELECT
Official_Correspondent.CONTACT_ID,
Official_Correspondent.FIRST_NAME,
Official_Correspondent.LAST_NAME,
Official_Correspondent.SUBACCOUNT_COMPANY_NAME,
Official_Correspondent.PHONE_NUMBER
FROM Official_Correspondent) AS Official_Correspondent
ON Contact_addresses.ContactID=Official_Correspondent.CONTACT_ID
)
;
I am trying to understand why my query(below) displays an error message in MS Access Sql query editor(sqlview) when I run it.
SELECT *
FROM tblUSPS
INNER JOIN tblProductUSPS
ON tblProductUSPS.[PRODUCTUSPS_USPS] = tblUSPS.[USPS_CODE]
INNER JOIN tblAttribute
ON tblUSPS.USPS_ID = tblAttribute.ATTRIBUTE_USPSID
As far as I know the script below if I delete either of the INNER join lines. For instance, this script runs with no errors
SELECT *
FROM tblUSPS
INNER JOIN tblProductUSPS
ON tblProductUSPS.[PRODUCTUSPS_USPS] = tblUSPS.[USPS_CODE]
And so does this
SELECT *
FROM tblUSPS
INNER JOIN tblAttribute ON tblUSPS.USPS_ID = tblAttribute.ATTRIBUTE_USPSID
But when I combine, something goes wrong and I am unable to find it so I would like some help identifying this please.
Access has strong opinions on parentheses.
SELECT *
FROM
(tblUSPS
INNER JOIN tblProductUSPS
ON tblProductUSPS.[PRODUCTUSPS_USPS] = tblUSPS.[USPS_CODE] )
INNER JOIN tblAttribute
ON tblUSPS.USPS_ID = tblAttribute.ATTRIBUTE_USPSID