![](/img/trans.png)
[英]How to compare column in one table with array from another table in BigQuery?
[英]selecting column names of one table from another table
我有 2 個表,table1 有 530 列,table2(有 421 列),table2 的所有列都在 table1 中。
我怎樣才能 select 只有表 1 中表 2 的列? 我在 Bigquery 中這樣做。 順便說一句,我在網上搜索了示例,但找不到解決方案。 謝謝你。
使用以下方法
execute immediate 'select ' ||
(select string_agg(col, ',' order by offset)
from (select col, offset from (select * from table1 limit 1) t, unnest(`bqutil.fn.json_extract_keys`(to_json_string(t))) col with offset)
join (select col from (select * from table2 limit 1) t, unnest(`bqutil.fn.json_extract_keys`(to_json_string(t))) col)
using(col) ) || ' from table1'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.