Question: I have two tables:

```
ID|name1|fkey
1 |foo  |345, 567

ID |name2 |
345|hello |
567|world |
789|bar   |

```

So the first table has a list of keys in one cell.
How can I join these tables to get the following result:

```
ID |name2|name1
345|hello|foo
567|world|foo
789|bar  | <null>

```

A usual join does not work, because the column "fkey" contains lists of keys.

Answer: 
use `split_part()` and left join

```
select t2.*,a.name1 from t2 left join
(select id,name1, split_part(fkey,',',1) as key1 
from t1
union 
select id,name1, split_part(fkey,',',2) as key1 
from t1
) a on a.key=t2.id

```
In postgresql if your column is an array you can do 

```
SELECT a.*
  FROM table1 AS a
  JOIN table2 AS b on a.id = ANY(b.column_array)

```

<https://www.postgresql.org/docs/9.2/arrays.html>