I want to get menu_id related all menu_id i.e, for menu_id 3 it should return
3,4,6,11
Following is my table:
I want to get menu_id related all menu_id i.e, for menu_id 3 it should return
3,4,6,11
Following is my table:
I think this query work for you:
SELECT @id := (SELECT ms_menu_id FROM ms_menu WHERE ms_menu_parent = @id)
AS menu_id FROM (SELECT @id := 3) vars STRAIGHT_JOIN ms_menu WHERE
@id !=0 union all (select ms_menu_id from ms_menu where ms_menu_id=3)
order by menu_id ASC limit 1, 18446744073709551615
results should be: 3,4,6,11