"Join Expression Not Supported" - Need help on Microsoft Access Query - sql

I need some help making the following SQL code work:
SELECT MemberData.MemberID, Transaction.TrxID, Transaction.Date,
Transaction.GroupID, TransactionDetails.CashIn, TransactionDetails.CashOut
FROM [Transaction]
INNER JOIN (MemberData LEFT JOIN TransactionDetails
ON MemberData.[MemberID] = TransactionDetails.[MemberID])
ON Transaction.[TrxID] = TransactionDetails.[TrxID];
An error stating below keeps popping up:
Join Expression Not Supported"
What am I doing wrong and how can I fix this?

I can't pinpoint the exact source of the error, but a simple fix for most of the Join expression not supported errors is to do one join at a time, and use subqueries.
SELECT MemberData.MemberID, T.TrxID, T.[Date],
T.GroupID, T.CashIn, T.CashOut
FROM (
SELECT [Transaction].TrxID, [Transaction].Date, [Transaction].GroupID, TransactionDetails.CashIn, TransactionDetails.CashOut, TransactionDetails.[MemberID]
FROM [Transaction]
LEFT JOIN TransactionDetails ON [Transaction].[TrxID] = TransactionDetails.[TrxID]
) AS T
INNER JOIN MemberData ON MemberData.[MemberID] = T.[MemberID];

#Poomind #Erik von Asmuth Just change the INNER JOIN into RIGHT JOIN You could try pasting the next SQL-statement into a new query.
SELECT MemberData.MemberID, T.TrxID, T.[Date], T.GroupID, T.CashIn, T.CashOut
FROM (SELECT [Transaction].TrxID, [Transaction].Date, [Transaction].GroupID,
TransactionDetails.CashIn, TransactionDetails.CashOut, TransactionDetails.[MemberID]
FROM [Transaction]
LEFT JOIN TransactionDetails ON [Transaction].[TrxID] = TransactionDetails.[TrxID])
AS T RIGHT JOIN MemberData ON MemberData.[MemberID] = T.[MemberID];
When I saved this query in a sample database, ms-access (version 2003) changed it to the following SQL-statement. So, don't worry if this happens with you too.
SELECT MemberData.MemberID, T.TrxID, T.[Date], T.GroupID, T.CashIn, T.CashOut
FROM [SELECT [Transaction].TrxID, [Transaction].Date, [Transaction].GroupID, TransactionDetails.CashIn, TransactionDetails.CashOut, TransactionDetails.[MemberID]
FROM [Transaction]
LEFT JOIN TransactionDetails ON [Transaction].[TrxID] = TransactionDetails.[TrxID]
]. AS T RIGHT JOIN MemberData ON MemberData.[MemberID] = T.[MemberID];

Related

LEFT JOIN expression not supported

I need to do a query with a left outer join just like below, however Access is showing a warning dialog "JOIN expression not supported".I understand that Access doesn't support INNER JOIN nested inside a LEFT JOIN but as I am a beginner in SQL I don't see any other way to get the same result.
The goal of the query is to get everything that is in the select even when InvoiceItems.Amount is null.
SELECT MainOrder.OrderNumber, OrderComponent.ArticleNumber, SupplierOrderMain.*, InvoiceItems.Amount
FROM InvoiceItems LEFT JOIN
((MainOrder INNER JOIN
OrderComponent
ON MainOrder.OrderNumber = OrderComponent.OrderNumber
) INNER JOIN
SupplierOrderMain
ON OrderComponent.ID = SupplierOrderMain.OrderComponentID
)
ON InvoiceItems.OrderComponent = OrderComponent.ID;
I'm not sure why you would want outer joins in this situation at all (you don't explain why). But just start with the table where you want to keep everything and work from there:
SELECT MainOrder.OrderNumber, OrderComponent.ArticleNumber, SupplierOrderMain.*, InvoiceItems.Amount
FROM ((InvoiceItems LEFT JOIN
OrderComponent
ON InvoiceItems.OrderComponent = OrderComponent.ID
) LEFT JOIN
MainOrder
ON MainOrder.OrderNumber = OrderComponent.OrderNumber
) LEFT JOIN
SupplierOrderMain
ON OrderComponent.ID = SupplierOrderMain.OrderComponentID

Multiple join with SQL

I have a problem with my SQL query.
I want to have a multiple join, but the error is not helpful.
The following is my query:
SELECT bn_ms_bm_bankmaster.CMP_CUSTCODE AS Id_client
,BN_CS_MP_MASTERPROFILE.CMP_NAME AS Nom_prenom
,PR_GN_AD_ENTITYADDRESS.PMP_MUNCIPCODE
FROM bn_ms_bm_bankmaster
INNER JOIN BN_CS_MP_MASTERPROFILE ON bn_ms_bm_bankmaster.CMP_CUSTCODE = BN_CS_MP_MASTERPROFILE.CMP_CUSTCODE
INNER JOIN PR_GN_AD_ENTITYADDRESS ON bn_ms_bm_bankmaster.CMP_CUSTCODE = PR_GN_AD_ENTITYADDRESS.CMP_CUSTCODE
This query give back to me the flowing error:
Impossible to add table bn_ms_bm_bankmaster with Microsoft Query
Any help will welcome.
Can you try with below.
select * from(Select bn_ms_bm_bankmaster.CMP_CUSTCODE AS Id_client,BN_CS_MP_MASTERPROFILE.CMP_NAME as Nom_prenom,PR_GN_AD_ENTITYADDRESS.PMP_MUNCIPCODE FROM bn_ms_bm_bankmaster INNER JOIN BN_CS_MP_MASTERPROFILE ON bn_ms_bm_bankmaster.CMP_CUSTCODE=BN_CS_MP_MASTERPROFILE.CMP_CUSTCODEINNER JOIN PR_GN_AD_ENTITYADDRESS ON bn_ms_bm_bankmaster.CMP_CUSTCODE=PR_GN_AD_ENTITYADDRESS.CMP_CUSTCODE);
Please try this.
Select A.CMP_CUSTCODE AS Id_client,
B.CMP_NAME as Nom_prenom,
C.PMP_MUNCIPCODE
FROM bn_ms_bm_bankmaster AS A
INNER JOIN BN_CS_MP_MASTERPROFILE AS B ON A.CMP_CUSTCODE= B.CMP_CUSTCODE
INNER JOIN PR_GN_AD_ENTITYADDRESS AS C ON B.CMP_CUSTCODE = C.CMP_CUSTCODE

INNER JOIN BIZZARE ERROR

I'm building a query to pull data from mutliple tables to generate a report, but the INNER JOIN's give me a "Syntax error in JOIN operation." and highlight the ON keyword. I suspect this is a simple problem, but I cannot for the life of me figure it out. please help.
SELECT
[_MAIN_].ID,
[_MAIN_].Project,
[_MAIN_].Client,
[_MAIN_].Description,
[_MAIN_].[Sub Project],
Tasks.Task
FROM ( [_MAIN_]
INNER JOIN (Tasks ON [_MAIN_].Tasks = Tasks.ID))
Your parenthesis look off.
Try this:
SELECT
m.ID,
m.Project,
m.Client,
m.Description,
m.[Sub Project],
t.Task
FROM [_MAIN_] as m
INNER JOIN Tasks as t
ON m.Tasks = t.ID

syntax error in from clause in access

Below is my query and it says syntax error in from clause whereas it is perfectly working in SQL.After the error 'AS' is highlighted
SELECT
Table1.*,
emp_details_full1.*
FROM Table1
LEFT JOIN
((SELECT
iss_personal_detail.Specialization,
iss_personal_detail.New_rank,
iss_personal_detail.Induction_tr,
iss_personal_detail.Title,
iss_personal_detail.f_name,
iss_personal_detail.m_name,
iss_personal_detail.l_name,
iss_personal_detail.Father_Hus_Name,
iss_personal_detail.Category,
iss_personal_detail.Community,
iss_personal_detail.SEX,
iss_personal_detail.source_recruit,
iss_personal_detail.Pay_Parity,
iss_personal_detail.[Date_Pay_Parity],
iss_personal_detail.UPSC_Rank,
iss_personal_detail.dob,
iss_personal_detail.doj_govt,
iss_personal_detail.DOA_ISS,
iss_personal_detail.Batch,
iss_personal_detail.Year_of_Exam,
iss_personal_detail.Native_Distt,
iss_personal_detail.Native_State,
iss_personal_detail.[Highest Qualification],
iss_personal_detail.Languages_Known,
iss_personal_detail.Mother_Toung,
iss_personal_detail.Marital_Status,
iss_personal_detail.E_mail_ID,
iss_personal_detail.retire_reason,
iss_personal_detail.title_m,
Present_Posting.*,
ISS_MINISTRY_CODE_LIST.*,
ISS_DEPARTMENT_CODE_LIST.*,
ISS_CITY_CODE_LIST.*,
Desig_Code.*,
Grade_Code.Grade_code
FROM ISS_CITY_CODE_LIST
INNER JOIN( Grade_Code
INNER JOIN (Desig_Code
INNER JOIN (((iss_personal_detail
INNER JOIN Present_Posting
ON iss_personal_detail.OID = Present_Posting.OID)
INNER JOIN ISS_MINISTRY_CODE_LIST
ON Present_Posting.ministry = ISS_MINISTRY_CODE_LIST.MINISTRY_CODE)
INNER JOIN ISS_DEPARTMENT_CODE_LIST
ON Present_Posting.department = ISS_DEPARTMENT_CODE_LIST.DEPARTMENT_CODE)
ON Desig_Code.Code = Present_Posting.designation)
ON Grade_Code.Grade_code = Present_Posting.Grade)
ON ISS_CITY_CODE_LIST.city_code=Present_Posting.office_city
)) AS emp_details_full1 ON
(emp_details_full1.DEPARTMENT_CODE=Table1.department) AND
(emp_details_full1.MINISTRY_CODE=Table1.ministry) AND
(emp_details_full1.city_code=Table1.city) AND
(emp_details_full1.Grade_Code=Table1.grade)
WHERE Table1.grade='02';
The first thing I would do is take the inner select and create a view from it.
This will provide a simple, easy to read, easy to debug sql code.
CREATE VIEW emp_details_full1
AS
SELECT iss_personal_detail.Specialization, iss_personal_detail.New_rank,
iss_personal_detail.Induction_tr, iss_personal_detail.Title,
iss_personal_detail.f_name, iss_personal_detail.m_name,
iss_personal_detail.l_name, iss_personal_detail.Father_Hus_Name,
iss_personal_detail.Category, iss_personal_detail.Community,
iss_personal_detail.SEX, iss_personal_detail.source_recruit,
iss_personal_detail.Pay_Parity, iss_personal_detail.[Date_Pay_ Parity],
iss_personal_detail.UPSC_Rank, iss_personal_detail.dob,
iss_personal_detail.doj_govt, iss_personal_detail.DOA_ISS,
iss_personal_detail.Batch, iss_personal_detail.Year_of_Exam,
iss_personal_detail.Native_Distt, iss_personal_detail.Native_State,
iss_personal_detail.[Highest Qualification],
iss_personal_detail.Languages_Known,
iss_personal_detail.Mother_Toung, iss_personal_detail.Marital_Status,
iss_personal_detail.E_mail_ID, iss_personal_detail.retire_reason,
iss_personal_detail.title_m, Present_Posting., ISS_MINISTRY_CODE_LIST.,
ISS_DEPARTMENT_CODE_LIST., ISS_CITY_CODE_LIST., Desig_Code.*,
Grade_Code.Grade_code
FROM ISS_CITY_CODE_LIST INNER JOIN( Grade_Code INNER JOIN (Desig_Code INNER JOIN
(((iss_personal_detail INNER JOIN Present_Posting ON iss_personal_detail.OID =
Present_Posting.OID) INNER JOIN ISS_MINISTRY_CODE_LIST
ON Present_Posting.ministry = ISS_MINISTRY_CODE_LIST.MINISTRY_CODE)
INNER JOIN ISS_DEPARTMENT_CODE_LIST ON
Present_Posting.department = ISS_DEPARTMENT_CODE_LIST.DEPARTMENT_CODE) ON
Desig_Code.Code = Present_Posting.designation) ON Grade_Code.Grade_code =
Present_Posting.Grade)
ON ISS_CITY_CODE_LIST.city_code=Present_Posting.office_city
Then the rest of the sql would look like this:
SELECT Table1.,emp_details_full1.
FROM Table1 LEFT JOIN emp_details_full1
ON (emp_details_full1.DEPARTMENT_CODE=Table1.department) AND
(emp_details_full1.MINISTRY_CODE=Table1.ministry) AND
(emp_details_full1.city_code=Table1.city) AND
(emp_details_full1.Grade_Code=Table1.grade) WHERE Table1.grade='02';
Now, if you look closely, you can see that there is a closing bracket missing between the end of the ON clause and the start of the WHERE clause.
So to fix that:
SELECT Table1.,emp_details_full1.
FROM Table1 LEFT JOIN emp_details_full1
ON (emp_details_full1.DEPARTMENT_CODE=Table1.department) AND
(emp_details_full1.MINISTRY_CODE=Table1.ministry) AND
(emp_details_full1.city_code=Table1.city) AND
(emp_details_full1.Grade_Code=Table1.grade)) WHERE Table1.grade='02';
Isn't that much easier to work with?

Ambiguous outer join in MS Access

Trying to create an outer join on two other joined tables when recieving this error - I just dont see how to create two separate queries to make it work. Subqueries don't seem to work either, any help appreciated. I get errors for the below query, thanks.
SELECT
CardHeader.CardID, CardHeader.CardDescription, CardHeader.GloveSize,
CardHeader.GloveDescription, CardDetail.Bin, CardDetail.ItemID, Items.ItemDescription,
Items.VCatalogID, CardDetail.ChargeCode, CardDetail.Quantity, Items.Cost, CardColors.ColorID
FROM
((Items
INNER JOIN
(CardHeader INNER JOIN CardDetail ON CardHeader.CardID = CardDetail.CardID) ON Items.ItemID = CardDetail.ItemID)
LEFT JOIN
CardColors ON CardDetail.ItemID = CardColors.ItemID)
INNER JOIN
Colors ON CardColors.ColorID = Colors.ID
ORDER BY
CardHeader.CardID;
I tried the following which runs but asks for the following parameters (which it shouldnt)
CardHeader.ID, MainQry.CardID
SELECT
MainQry.ID, MainQry.CardDescription, MainQry.GloveSize,
MainQry.GloveDescription, MainQry.Bin, MainQry.ItemID,
MainQry.ItemDescription, MainQry.VCatalogID, MainQry.ChargeCode,
MainQry.Quantity, MainQry.Cost, SubQry.ColorID
FROM
(SELECT
CardHeader.ID, CardHeader.CardDescription, CardHeader.GloveSize,
CardHeader.GloveDescription, CardDetail.Bin,
CardDetail.ItemID, Items.ItemDescription, Items.VCatalogID,
CardDetail.ChargeCode, CardDetail.Quantity, Items.Cost
FROM
Items
INNER JOIN
(CardHeader
INNER JOIN
CardDetail ON CardHeader.CardID = CardDetail.CardID) ON Items.ItemID = CardDetail.ItemID
) AS MainQry
LEFT JOIN
(SELECT
CardColors.ItemID, CardColors.ColorID
FROM
CardColors
INNER JOIN
Colors ON CardColors.ColorID = Colors.ID) AS SubQry ON MainQry.ItemID = SubQry.ItemID
ORDER BY
MainQry.CardID;
The second SQL statement can be corrected by reference to the first statement and the error. The error is that both CardHeader.ID and MainQry.CardID are prompting for a parameter, which indicates that the inner statement should include CardHeader.CardID, rather than CardHeader.ID