Some RDBMSs like MySQL and MariaDB have a GROUP_CONCAT() function that allows you to return a query column as a delimited list (for example, a comma separated list).
PostgreSQL has a similar function called STRING_AGG(). This function works in pretty much the same way that GROUP_CONCAT() works in MySQL and MariaDB.