简体   繁体   English

BigQuery加入If

[英]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...]. 对于一个有关图书的项目,我有一个大表'Books',其中包含有关大量图书标题[作者,标题,pubDate等...]的详细信息。 I also have a table which contains pseudonyms information for authors who used them [authorName, pseudName]. 我还有一个表,其中包含使用它们的作者的假名信息[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. 我想做的是在“ Books”表中添加一列,如果该名称是笔名,则链接回作者的真实姓名;否则,如果不是笔名,则保留为作者名。 Normally would do some kind of IF EXISTS () INSERT INTO... but INSERTS aren't available in bigquery. 通常会做某种IF EXISTS()INSERT INTO ...,但在bigquery中不可用INSERTS。

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. 我知道如何进行将假名链接回作者姓名的联接,但是如果不是假名,则无法弄清楚如何将该值保留为原始作者名。

也许您可以将其作为LEFT OUTER JOIN,然后将IFNULL(pseudName,authorName)放入

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM