Dynamic column in SELECT statement postgres

后端 未结 6 1658
温柔的废话
温柔的废话 2020-12-20 14:55

I am quite new to the postgresql.

what is the best way to achieve this?

SELECT get_columns() 
  FROM table_name;

get_columns(

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-20 15:55

    In order to write a dynamic query you would have to do something like:

    EXECUTE 'SELECT '|| get_columns()|| ' FROM table_name' INTO results
    

    Please read the documentation: http://developer.postgresql.org/pgdocs/postgres/plpgsql-statements.html

提交回复
热议问题