SQL left join

Hello,

I'm trying to setup a left join

SELECT "view_123"."tab1"."ID",
"view_123"."Tab1"."group1_id" as "Groupe1 (ID)",
"pg1"."NAME" as "Groupe1 (Name)",
"view_123"."Tab1"."group2_id" as "Groupe2 (ID)",
"pg2"."NAME" as "Groupe2 (Name)"
FROM "view_123"."Tab1"
LEFT JOIN "view_123"."groupTable" "pg1" ON "view_123"."tab1"."group1_id" = "pg1"."ID"
LEFT JOIN "view_123"."groupTable" "pg2" ON "view_123"."tab1"."group2_id" = "pg2"."ID" 

Error :

ERROR: invalid reference to an entry in the FROM clause for table 'groupTable' Hint: Maybe you want to reference the alias for table 'pg1'. Location: 519

Reference (I'm the author of the question) :

How can I setup something similar to the stackoverflow question ?

Hi @Exe
Your stackoverflow question is for MySQL, but the snippet you are including is for a different database type. Be aware of case-sensitivity, meaning "tab1" is not the same as "Tab1"
The error is not coming from Metabase - it's coming from your database, so make sure that you are using a correct, valid query.

SELECT "ID",
"pg1"."ID" as "Groupe1 (ID)",
"pg1"."NAME" as "Groupe1 (Name)",
"pg2"."ID" as "Groupe2 (ID)",
"pg2"."NAME" as "Groupe2 (Name)"
FROM "view_123"."tab1"
LEFT JOIN "groupTable" "pg1" ON "tab1"."group1_id" = "pg1"."ID"
LEFT JOIN "groupTable" "pg2" ON "tab1"."group2_id" = "pg2"."ID"