dpick
dpick

Reputation: 35

BigQuery Join If

For a project about books, I have a large table 'Books' with details about a large number of book titles [author, title, pubDate, etc...]. I also have a table which contains pseudonyms information for authors who used them [authorName, pseudName].

What I want to do is add a column to the 'Books' table that links back to the author's real name if the name is a pseudonym, otherwise stays as the author name if it is not a pseudonym. Normally would do some kind of IF EXISTS () INSERT INTO... but INSERTS aren't available in bigquery.

I know how to do the join to link the pseudonyms back to the author name, but can't figure out how to keep the value as the original author name if it is not a pseudonym.

Upvotes: 1

Views: 77

Answers (1)

Mosha Pasumansky
Mosha Pasumansky

Reputation: 14014

Perhaps you can do it as LEFT OUTER JOIN, and then put IFNULL(pseudName, authorName)

Upvotes: 1

Related Questions