[英]Using SQL, how do you find the child number in a table from two columns where they are parent-child relationships?
A scalar subquery will produce the data you want.标量子查询将产生您想要的数据。 For example:
例如:
select
t.*,
(select count(*) from t b where b.parent_id = t.id) as child
from t
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.