SQL Join - Syntax error (missing operator) when using two Joins in query

PavelSimek

New Member
Joined
Jul 28, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Please help... In Invoices table record in my "Excel database" i keep supplier ID and customer ID when I list all invoices for a certain period i need names instead of IDs. With one INNER JOIN (for only one "BusinessPartner") the query works, as soon as I use two it reports an error.

SELECT
Invoices.ID,
Supplier.BusinessPartnerName AS SupplierName,
Customer.BusinessPartnerName AS CustomerName,
Invoices.VS,
Invoices.Total
FROM
[Invoices$] as Invoices
INNER JOIN
[BusinessPartners$] AS Supplier ON Invoices.SuppID = Supplier.ID;
INNER JOIN
[BusinessPartners$] AS Customer ON Invoices.CustID = Customer.ID
WHERE
Invoices.DueDateUS >= #06/24/2024# AND Invoices.DueDateUS <= #07/24/2024# AND (Invoices.AlreadyPayed = 'FALSE' OR Invoices.NotPayed = 'FALSE') ORDER BY Invoices.DueDateUS DESC

Thank you in advance,
Pavel
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Remove the semi colon after the first INNER JOIN line

PS: I would use Power Query to merge tables in Excel
 
Last edited:
Upvote 0
Remove the semi colon after the first INNER JOIN line

PS: I would use Power Query to merge tables in Excel
Thank you very much for the answer, the semicolon is not the problem (I didn't have it in the original query), the problem is the syntax of two consecutive JOIN statements. When I use one JOIN, the query runs fine, as soon as I add the second one (to same table, just on a different record), Excel reports a syntax error (missing operator). I will try Power Query, thanks for the tip.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,183
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top