How to convert row into column with random with mysql? Distinct (image_url)
select p.email ,
image_url AS image_url_1,
image_url AS image_url_2 ,
image_url AS image_url_3,
image_url AS image_url_4
FROM
poll p
GROUP BY
email
ORDER by RAND()
Also, in this query
select email,
(select IFNULL((image_url from poll p1 order by rand() limit 1), NULL) as image_1,
(select IFNULL((image_url from poll p2 order by rand() limit 1), NULL) as image_2,
(select IFNULL((image_url from poll p3 order by rand() limit 1), NULL) as image_3,
(select IFNULL((image_url from poll p4 order by rand() limit 1), NULL) as image_4
from poll
group by email
How to display null
if there is less than 4 image_url and how to make it distinct?