CREATE TABLE public.t1
(
id character varying(24) NOT NULL,
ratings integer[]
)
CREATE TABLE public.t2
(
id character varying(24) NOT NULL,
rating integer
)
SELECT * FROM t1
INNER JOIN t2 ON IF t1.ratings.length > 0 THEN t2.rating = any(t1.ratings) ELSE true