1、SELECT
*
FROM
(
SELECT
d.id,
( SELECT count( 1 ) FROM t_tree dd WHERE dd.parent_uuid = d.id ) AS count
FROM
t_tree d
) a
WHERE
a.count =0;
2、SELECT
t3.id
FROM
t_tree t3
WHERE
t3.id NOT IN ( SELECT t1.id FROM t_tree t1, t_tree t2 WHERE t1.id = t2.parent_uuid )
2022-06-19 19:03:24
29KB
mysql
1