Skip to content
Advertisement

Bigquery Full Join ON multiple conditions

I want to perform a Full Outer join on two tables with multiple conditions to result all the matching records along with unmatched records from both tables. Tbl1 is a bigger table with 21 M records and Tbl2 has 5k rows, like the example query below. But the outer join cannot be performed with OR conditions because of the error ‘FULL OUTER JOIN cannot be used without a condition that is an equality of fields from both sides of the join’. Is writing separate queries, then use COALESCE the only solution in this case? I am not sure how to implement this solution. Looking for any help to get this correct.

Example code –

Advertisement

Answer

Just move your conditions from ON to WHERE and optionally optimize all those ORs as in below

so you final query can look like below

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement