Forum Moderators: open
Table 1 Fields:
+ idsubject (key)
+ another fields....
Table 2 Fields:
+ idfollow (key)
+ idsubject (relation with Table 1)
+ another fields....
One,Two or more idfollow's in Table 2 could have the same idsubject and I want to show a query where I could see each idsubject and how many idfollow's has. If an idsubject do not have any idfollow I want to show "0".
Is there any good person, please :)?
How about a LEFT JOIN?
SELECTThis would return all the rows in table1 and any related rows in table2. If there were no related rows in table2, then table2.idfollow would be
table1.idsubject,
table2.idfollow
FROM table1
LEFT JOIN table2
ON (table1.idsubject=table2.idsubject)
ORDER BY table1.idsubject, table2.idfollow
;
NULL(not zero as you asked). Would this work for you?
union
Select table1.idsubject,0
From table1
Where table1.idsubject NOT IN (Select Distinct idsubject from table2)
Thats how to do it in SQL whether ACCESS supports all these statements is another matter!