This is my query:
___________________________________________________________
SELECT elt1.name, COUNT(elt2.name)
FROM (elementlinks AS el_link INNER JOIN elements AS elt1 ON el_link.n1=elt1.id)
INNER JOIN elements AS elt2 ON el_link.n2=elt2.id
WHERE elt1.typeid=2 AND elt2.name IN
(
SELECT elements.name
FROM elements INNER JOIN data ON elements.id=data.ownerid
WHERE data.typeid=10 AND data.valuer=1
)
GROUP BY elt1.name;
_______________________________________________________
elt1 are programs and elt 2 are classes in an 'elements' table linked in 'elementlinks' table. The data is the number of parents for a class. So this query counts for each program the number of classes having one parent. It returns only programs containing at least one class with one parent, but i'd like to have too programs not concerned.
Actually, i'd like to have in my query all programs listed, those not concerned may have a 0 for number of concerned classes. But this query doesn't match, it displays
PROGRAMS NB_OF _CLASSES_WITH_ONE_PARENT
elt11 1
elt13 3
elt14 2
elt16 1
AND i want:
PROGRAMS NB_OF _CLASSES_WITH_ONE_PARENT
elt11 1
elt12 0
elt13 3
elt14 2
elt15 0
elt16 1
If any ideas, thanx a lot.
___________________________________________________________
SELECT elt1.name, COUNT(elt2.name)
FROM (elementlinks AS el_link INNER JOIN elements AS elt1 ON el_link.n1=elt1.id)
INNER JOIN elements AS elt2 ON el_link.n2=elt2.id
WHERE elt1.typeid=2 AND elt2.name IN
(
SELECT elements.name
FROM elements INNER JOIN data ON elements.id=data.ownerid
WHERE data.typeid=10 AND data.valuer=1
)
GROUP BY elt1.name;
_______________________________________________________
elt1 are programs and elt 2 are classes in an 'elements' table linked in 'elementlinks' table. The data is the number of parents for a class. So this query counts for each program the number of classes having one parent. It returns only programs containing at least one class with one parent, but i'd like to have too programs not concerned.
Actually, i'd like to have in my query all programs listed, those not concerned may have a 0 for number of concerned classes. But this query doesn't match, it displays
PROGRAMS NB_OF _CLASSES_WITH_ONE_PARENT
elt11 1
elt13 3
elt14 2
elt16 1
AND i want:
PROGRAMS NB_OF _CLASSES_WITH_ONE_PARENT
elt11 1
elt12 0
elt13 3
elt14 2
elt15 0
elt16 1
If any ideas, thanx a lot.