Select columns with the same prefix [duplicate]
问题 This question already has answers here : Use text output from a function as new query (2 answers) Closed 4 years ago . Using the following code I can select a few columns that share the same prefixes (either upreg_srt or downreg_srt) from my table and delete (drop) them: DO $do$ DECLARE _column TEXT; BEGIN FOR _column IN SELECT DISTINCT quote_ident(column_name) FROM information_schema.columns WHERE table_name = 'all_se_13patients_downreg_ranks' AND column_name LIKE '%upreg_srt' OR column_name