Select All Columns Except Some in Google BigQuery?

后端 未结 2 1010
自闭症患者
自闭症患者 2021-02-05 00:59

Is there a way to Select * except [x,y,z column names] in BigQuery? I see some solutions for MySQL but not sure if it applies to BQ.

Thank you.

2条回答
  •  孤街浪徒
    2021-02-05 01:31

    In addition to SELECT * EXCEPT() syntax there is a SELECT * REPLACE() syntax - both supported with Standard SQL introduced
    Usage is simple and obvious as per documentation

    What is less obvious is that you can use both together in the same SELECT, like in example below

    WITH orders AS
      (SELECT 5 as order_id,
      "sprocket" as item_name,
      200 as quantity)
    SELECT * EXCEPT (order_id) REPLACE ("widget" AS item_name), "more" as more_fields
    FROM orders;
    

提交回复
热议问题