SSK
SSK

Reputation: 803

How can i have INNER and LEFT JOIN in the same query?

I am trying to do an INNER JOIN and LEFT JOIN in the same query in MS ACCESS and here is my query

SELECT T2.Col1, T2.Col2, T2.Col3, TB.Col1
FROM (T2

INNER JOIN TB ON
TB.Col1 = T2.Col1 AND TB.Col2 = T2.Col2)

LEFT JOIN T1
ON (T1.Col1 = TB.Col1) AND (T1.Col2 = T2.Col2) 
WHERE T1.Col1 IS NULL OR T1.Col2 IS NULL

But at (T1.Col1 = TB.Col1)` it says JOIN Expression not supported. Can some one help me with this.

I don't want to create an inner query and then create another left query with that seperately

Upvotes: 1

Views: 150

Answers (1)

You can assing an "alias" when you call your table "from T2 t" and "INNER JOIN TB s" when you put the letter after the name of the table, it already takes it as an alias, so you can reference it easier

SELECT t.Col1, t.Col2, t.Col3, s.Col1

FROM T2 t

INNER JOIN TB s 

ON (t.Col1 = s.T2.Col1 AND t.Col2 = s.Col2)

if there are only two tables, you only need 1 inner join

Upvotes: -1

Related Questions