I've this query
SELECT t1.categoryid AS lev1, t2.categoryid as lev2, t3.categoryid as lev3, t4.categoryid as lev4
FROM category AS t1
LEFT JOIN category AS t2 ON t2.parent = t1.categoryid
LEFT JOIN category AS t3 ON t3.parent = t2.categoryid
LEFT JOIN category AS t4 ON t4.parent = t3.categoryid
WHERE t1.categoryid = 4149418031;
This is how to result looks like
As you can see it returns four columns. I want to merge distinct data of all four into one column.
I looked at similar questions but none of those has Left Joins in their query.
I know it can be possible using union
but I'm struggling.
Thanks.