steveosoule
1/13/2015 - 12:59 AM

SQL - Recursive Hierarchy

SQL - Recursive Hierarchy

-- FROM: http://stackoverflow.com/questions/16513418/how-to-do-the-recursive-select-query-in-mysql
-- Example: http://sqlfiddle.com/#!2/9635d2/1

select col1, col2, @pv:=col3 as 'col3' from table1
join
(select @pv:=1)tmp
where col1=@pv