In MySQL I use GROUP_CONCAT()
function, nevertheless now i need to convert that to Postgres. Can anyone help me out how to convert such query into Postgres? I think the only one which has to be replaced is the line with GROUP_CONCAT
?
SET @sql = NULL;
SELECT CONCAT(
'SELECT ',GROUP_CONCAT(c.TABLE_NAME,'.',c.COLUMN_NAME,' AS `',c.TABLE_NAME,'.',c.COLUMN_NAME,'`'),'
from t1 AS thre
inner join t2 as ter on thre.datasource = ter.datasource
inner join t3 as ston on thre.datasource = ston.datasource
inner join t4 as diron on thre.datasource = diron.datasource'
)
INTO @sql
FROM INFORMATION_SCHEMA.COLUMNS c
WHERE c.TABLE_NAME IN ('t1','t2',
't3','t4');
PREPARE sql_statement FROM @sql;
EXECUTE sql_statement;