I am trying to use string aggregation on the results of a subquery that contains concatenated results. I would like to create a long text string containing the qualified name "schema.table" for a DB schema I have in Postgres. Do you know how to achieve it? Below is the code I have come up with (not working), it says more than one row returned by a subquery used as an expression.
SELECT string_agg(
(SELECT CONCAT(table_schema, '.', table_name) table_schema_name
FROM information_schema.tables
WHERE table_schema = 'name_of_schema'), ' ')
FROM information_schema.tables
WHERE table_schema = 'name_of_schema'
what I have now is:
| table_schema_name |
name_of_schema.table1
name_of_schema.table2
name_of_schema.table3
What I would like to achieve is:
| agrreagated field |
name_of_schema.table1 name_of_schema.table2 name_of_schema.table3