I am quite new to the postgresql.
what is the best way to achieve this?
SELECT get_columns()
FROM table_name;
get_columns()
will provide the column names for the query. I saw people advising to use EXECUTE statement but I couldn't got that working.
Lets say there is table Test with columns a,b,c
and I want to run
SELECT a,b FROM Test;
SELECT a,c FROM Test;
with column names generated dynamically.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…