Question:
For MS Access, how to count records in Child Table and display in related Parent Table?
musical_bell
2008-03-27 02:26:59 UTC
I have 2 MS Access tables:
(1) Blogs with columns:
"BlogID" (primary key, AutoNumber), "DateNTime", "BlogEntry"
(2) Comments with columns:
"BlogID" (foreign key, Number), "CommentID" (AutoNumber), "CommenEntryt"

I have set a relationship between these two tables where Blogs is the parent table while Comments is the child table. By the way, am I right to call "BlogID" in Comments table "foreign key"?

This should work rather simple. Every time I enter a new BlogEntry, a BlogID will be generated automatically. When someone enter a BlogComment corresponds to a BlogID, CommentID will be generated automatically. So now, I would like to add a new column under BlogID to count how many BlogComment s are there under each BlogID. How can I do that?

I heard that I can do it by creating a query but I don't know how to do so. Can someone please teach me?

Thanks a lot...
Four answers:
doug a
2008-03-27 04:37:47 UTC
create the wuery you require then use the field you want to count on then use the sigma sign next to the red excamation mark.



There will be a new row at the bottom with a group by in it change it to count.



the jobs done.



If you put the same field in twice one group by the next count you will se what I mean.



Have a go if you get stuck contact me
2008-03-27 02:38:40 UTC
in a query the first thing goes is the question u need to know the answer then u giv from then the database file name then u giv wher then u write the condition

eg. u need to know the details of pupil's name who has the telephone no 2753

so ur query goes on

Select * Pupil name from Student Details where Pupil no. = 2753;

Remember the field name n the database file name should be same. If u need to know the details i mean tat u want the computer to show u the etire record of a field so u hav to giv * or if want only the pupil's name (given above as an eg.) so after Select there will be Pupil Name. u hav to rember also tat at the end u have to give cotations if the query ends with a word after tat this ; and if ends with no so u can end with this ;
?
2016-10-15 09:12:20 UTC
in a query the 1st ingredient is going is the question u might desire to nicely known the respond then u giv from then the database report call then u giv wher then u write the circumstance eg. u might desire to nicely known the biggest factors of student's call who has the telephone no 2753 so ur question is going on elect * student call from student info the place student no. = 2753; bear in techniques the sphere call n the database report call must be comparable. If u might desire to nicely known the biggest factors i advise tat u prefer the laptop to teach u the etire checklist of a field so u hav to giv * or if prefer in user-friendly terms the student's call (given above as an eg.) so after elect there will be student call. u hav to rember additionally tat on the top u ought to offer cotations if the question ends with a be conscious after tat this ; and if ends without so u can end with this ;
future_evolium
2008-03-27 02:31:15 UTC
use a new field with dedicated name but which must have autoincrement. Then in parent table make a link to that field and you can very east display the record number addressing that field.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...