Skip to content

Instantly share code, notes, and snippets.

@AnishLushte07
Created July 31, 2019 09:52
Show Gist options
  • Save AnishLushte07/981d4d9229afc482602e62efae7ac97a to your computer and use it in GitHub Desktop.
Save AnishLushte07/981d4d9229afc482602e62efae7ac97a to your computer and use it in GitHub Desktop.
Tree selection sql
select id,
name,
parent_id
from (select * from user_categories
order by parent_id, id) products_sorted,
(select @pv := '104') initialisation
where find_in_set(parent_id, @pv)
and length(@pv := concat(@pv, ',', id))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment