I need select data from table like this (its just example).
I want select data in format like Category1,Category2,Category3 without root by parent_id
The result should be
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
This behaviour could be achieved using self joins.
This should do the trick:
select a.name as category1, b.name as category2, c.name as category3 from yourtable a left join yourtable b on a.id_category = b.parent_id left join yourtable c on b.id_category = c.parent_id where a.id_category in (2,3);