Your query works correctly.
Also I like the idea how you include the WHERE clause and `mytable`.`id` inside subquery, very nice.
I will post here (Just for community wiki) another solution, using User Defined Variables inside User Defined Function to "return" multiple variables.
Code:
DELIMITER $$ CREATE DEFINER=`dbuser`@`localhost` FUNCTION `getchildren`(
Leave a comment: