In my database I have a table relations
with a column relation_ids
containing the IDs of users (user_id
). This takes the form of an array with many IDs possible, e.g.:
{111,112,156,4465}
I have another table names
containing information on users such as user_id
, first_name
, last_name
etc.
I would like to create an SQL query to return all rows from relations
with all columns, but append the array column relation_ids
with first_name
from the names
table substituted for IDs.
Is it possible as some kind of subquery?