Hardik Aswal
Hardik Aswal

Reputation: 227

How to find all the column names of a table where the column names match a certain string? (BigQuery)

How to get a list of all the columns inside a bigquery table which contain a particular keyword? For eg. Say the table has following columns:

Name | Age | Address | School_Name | School_Address | School_PhoneNo | etc. I want the names of all the columns which contain the string 'School'. The required result would be:

  1. School_Name
  2. School_Address
  3. School_PhoneNo

Upvotes: 1

Views: 377

Answers (1)

Pentium10
Pentium10

Reputation: 207912

You need to run a query like

SELECT
 column_name
FROM
 `bigquery-public-data`.census_bureau_usa.INFORMATION_SCHEMA.COLUMNS
WHERE
 column_name like '%age%' and table_name='population_by_zip_2000'

This returns:

enter image description here

Upvotes: 2

Related Questions