Hello Experts i have node table which has nodeid and parentid columns and i trying to get list of all nodes in such a way that parent nodes are listed before child nodes .
In this sqlfiddle example i am not getting node id 20,21 as result
Query i have used is
select nodeid,parentid from
(select * from node
order by parentid, nodeid) channel_sorted,
(select @pv := '0') initialisation
where find_in_set(parentid, @pv) and length(@pv := concat(@pv, ',', nodeid))
parent_idcannot exist without it existing itself. In your case, how did you end up with(19, 'categor19', 2296)? You are facing this issue because of a poor design. You may still achieve this with PHP as shown here.