I am using two tables:
tbl_category, {"id", "title", "details"}
tbl_items, {"id" "title", "parents"}
Right now i am using the below query, but have to use 'tbl_category' twice. Can it be more simplified?
SELECT a.id
, a.title
, a.details
, d.itemscount
FROM tbl_category a
LEFT
JOIN
( SELECT b.id myid
, COUNT(c.id) itemscount
FROM tbl_category b
LEFT
JOIN tbl_items c
ON FIND_IN_SET(b.id,c.parents)
GROUP
BY b.id
) d
ON d.myid = a.id