Reputation: 15
I am trying to achieve the following in goggle big query however struggling with syntax in Standard SQL Dialect
SELECT DB.Table1.Key1,DB.Table3.Name ]
Where Table1.Key1=Table2.Key1, Table2.Key2=Table3.Name
Where the below is an abstract of the tables
+---------+-----------+-----------+
| Tabel 1 |Table 2 |Table 3 |
| key1(PK)| Key1(FK) | Key2(FK) |
| | Key2(PK) | Name |
+---------+-----------+-----------+
SELECT key
FROM `DB.Table1`
union DISTINCT
SELECT key, Key2
from
`DB.Table2`
union DISTINCT
SELECT Key2
from`DB3`
Upvotes: 0
Views: 63
Reputation: 31993
use standard sql mode try like below by using join
SELECT Table1.Key1,Table3.Name
from Table1 join Table2
on Table1.Key1=Table2.Key1
join Table3 on Table2.Key2=Table3.Name
Upvotes: 1