mysql - Query in a LIKE-TREE table -
i have table following columns:
idcat, idparent, des
idcat autoincremented, des description , idparent can "0" if record parent or can have "idcat" value of parent if child.
i need query select "des" of record not have child, this:
select des table having count (idcat=idparent) = 0
obviously query doesn't work.
can me please?
this can done via not in, not exists or left join ... null - latter best-performing in mysql:
select t1.des table t1 left join table t2 on t1.idcat = t2.idparent t2.idparent null
Comments
Post a Comment