How to store all the values in a row to array in postgresql?

Member

by jasen , in category: MySQL , 4 months ago

How to store all the values in a row to array in postgresql?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by samara , 2 months ago

@jasen 

You can store all the values in a row to an array in PostgreSQL by using the ARRAY function.


Here is an example of how you can store all the values in a row to an array in PostgreSQL:

1
2
3
SELECT ARRAY[column1, column2, column3]
FROM your_table
WHERE condition = 'your_condition';


This query will select values from column1, column2, and column3 in the row that meets the specified condition and store them in an array. Note that you need to replace your_table with the actual table name and your_condition with the condition you want to filter the rows by.