Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BigQuery JOIN on two tables

I'm trying to run the following query but keep on encountering the same error

Query Failed Error: Encountered "" at line 6, column 33. Was expecting one of:

The query is:

SELECT 1_0_MEMBER_GROUP.User_Group,
1_0_MEMBER_GROUP.Member_ID,
1_4_MEMBER_TRAN_YEAR.MEMBER_UID
FROM [Dataset1.1_0_MEMBER_GROUP]
JOIN [Dataset1.1_4_MEMBER_TRAN_YEAR]
ON 1_0_MEMBER_GROUP.Member_ID = 1_4_MEMBER_TRAN_YEAR.MEMBER_UID

I can't work out why it won't run and must be over looking something very simple.

like image 828
DWGKNZ Avatar asked Sep 18 '12 10:09

DWGKNZ


People also ask

How do I combine two tables in BigQuery?

Click the join and choose Delete. Create a new join by dragging the column name from the second table to the corresponding column name in the first table. Click Execute SQL. If a preview of your data appears in the Sample Preview pane, the join was successfully created.

What is cross join in BigQuery?

Cross joins (Cartesian product) Cross joins are queries where each row from the first table is joined to every row in the second table (there are non-unique keys on both sides). The worst case output is the number of rows in the left table multiplied by the number of rows in the right table.

Can we use CTE in BigQuery?

Common table expressions (CTEs) help you break up complex queries in BigQuery. Here's a simple query to illustrate how to write a CTE: with beta_users as ( select * from users where beta is true ) select events. * from events inner join beta_users on beta_users.id = events.


1 Answers

You should use a table alias. Try

SELECT member_group.User_Group, 
member_group.Member_ID, 
member_tran_year.MEMBER_UID 
FROM [Dataset1.1_0_MEMBER_GROUP] as member_group
JOIN [Dataset1.1_4_MEMBER_TRAN_YEAR] as member_tran_year
ON member_group.Member_ID = member_tran_year.MEMBER_UID
like image 84
Jordan Tigani Avatar answered Oct 14 '22 07:10

Jordan Tigani