SELECT parent.*, (main.level - parent.level + 1) as lvl, u.name
FROM books main
LEFT JOIN books parent ON parent.lft < main.lft AND parent.rgt > main.rgt AND parent.level = main.level - $line
LEFT JOIN users u ON u.id = parent.user_id
WHERE main.id = :id