[SalesForce] Data extension Inner Join – Incorrect syntax near the keyword ‘WHERE’

I am trying to join 2 data extensions and input the result to a third data extension:

SELECT [Account ID] AS [Account ID], [Created Date Backend] AS [Created Date] 
FROM [DE A]  A
INNER JOIN [DE B] B
WHERE A.[Account ID] = B.[Lead ID]

Currently getting a syntax error:

The query syntax is invalid
Incorrect syntax near the keyword 'WHERE'.

What am I doing wrong?

Best Answer

When conducting a JOIN function, you need to specify what the 2 tables are joining on.

Try this:

SELECT 
[Account ID] AS 'Account ID'
,[Created Date Backend] AS 'Created Date'
FROM [DE A] A
INNER JOIN [DE B] B ON A.[Account ID] = B.[Lead ID]

Note that you may need to specify what table Account ID and Created Date Backend come from.

Reference: https://www.w3schools.com/sql/sql_join.asp

This image will help you understand the basics of JOINs: SQL Joins

Related Topic