Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Correct syntax for table name under Inner Join?

I am a complete beginner to BigQuery, and I am trying to create an inner join between two table names, where the column ‘title’ is the joining column. I believe my syntax is correct, but I do not know what I am doing wrong when I input the ON clause. Here is my syntax:
SELECT
*
FROM
book-to-film-adaptations.movies.movies_metadata_relevant
JOIN
book-to-film-adaptations.goodreads_books.goodreads_books_relevant_data
ON
movies_metadata_relevant.title = goodreads_books_relevant_data.title

I get this error message: Unrecognized name: movies_metadata_relevant at [8:3]
I have tried it with the full names (book-to-film-adaptations.movies.movies_metadata_relevant), but then I get an error message: "Syntax error: Unexpected keyword TO"

Any suggestions?
Thanks

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need to alias tables and use those like in below example – but in this case you will need

... 
  ...
FROM
  `book-to-film-adaptations.movies.movies_metadata_relevant` t1
JOIN
  `book-to-film-adaptations.goodreads_books.goodreads_books_relevant_data` t2
ON
  t1.title = t2.title       

or if join columns have same name (like in your case) you can use below version

... 
  ...
FROM
  `book-to-film-adaptations.movies.movies_metadata_relevant` t1
JOIN
  `book-to-film-adaptations.goodreads_books.goodreads_books_relevant_data` t2
USING (title)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading