简体   繁体   English

BigQuery 标准 SQL SELECT 行 WHERE 字段包含来自另一个表字段的单词

[英]BigQuery Standard SQL SELECT rows WHERE field contains words from another table field

I have 2 tables in BigQuery.我在 BigQuery 中有 2 个表。 VIDEOS table contains video names and tags. VIDEOS 表包含视频名称和标签。 CREATORS table contains information about video creators. CREATORS 表包含有关视频创作者的信息。 The VIDEOS.tags field contains comma separated quoted strings. VIDEOS.tags 字段包含逗号分隔的带引号的字符串。

I need to select all the videos that were tagged with names in the CREATORS table with results looks like this:我需要在 CREATORS 表中选择所有标有名称的视频,结果如下所示:

Title 1, Creator 1
Title 2, Creator 2
Title 3, Creator 2
Title 4, Creator 3
Title 5, Creator 3
...

But what I have below does not return any results in BigQuery.但是我下面的内容在 BigQuery 中没有返回任何结果。

SELECT
    B.name AS Title,
    C.creator_name AS Creator
FROM `project.database.VIDEOS` AS B, `project.database.CREATORS` AS C
WHERE B.tags LIKE CONCAT('%"', C.creator_name ,'"%')

在这种情况下,通常是因为情况不同 - 尝试

WHERE LOWER(B.tags) LIKE CONCAT('%"', LOWER(C.creator_name) ,'"%')

I think you want it the other way around: The tag has to look like the name.我想你想要反过来:标签必须看起来像名字。 Let me know让我知道

SELECT
    B.name AS Title,
    C.creator_name AS Creator
FROM `project.database.VIDEOS` AS B, `project.database.CREATORS` AS C
WHERE C.creator_name LIKE CONCAT('%"', B.tags ,'"%')

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

相关问题 SQL选择行,其中字段包含来自另一个表的字段的单词 - SQL select rows where field contains word from another table's fields SQL SELECT仅包含单词的字段 - SQL SELECT only field where it contains words SQL SELECT WHERE字段包含单词 - SQL SELECT WHERE field contains words 选择记录,其中表中的单词出现在另一个表的字段中 - select records where words from a table appear in a field on a different table SQL SELECT字段contains(words)不起作用 - SQL SELECT field contains(words) does not work 在SQL中,如何从表中选择*,但是当多行具有相同的字段时,只选择另一个字段B为MAX的那些? - In SQL, how do I select * from a table, but when multiple rows have the same field, select only the ones where another field B is MAX? 从不同表的列中获取字段包含文本的行? - Get rows where a field CONTAINS text from a column in a different table? SQL 如果字段为“*”,则从另一个表中选择 - SQL If field is '*' then select from another table T-SQL选择记录,其中某个字段包含另一个表中的某个关键字 - T-SQL selecting records where a field contains a certain keyword from another table 标准sql查询以获取与另一个表匹配的记录字段(Google BigQuery) - standard sql query to get matching record field with another table (Google BigQuery)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM