Dear esteemed friends and other great minds,
I pose this question to you:
How do I count the number of records associated with a different record?
SELECT FOLDERS.Folder_Name, FOLDERS.Folder_Id,
COUNT(FILES.Folder_Id = FOLDERS.Folder_Id) AS File_Count
FROM FOLDERS,FILES GROUP BY Folder_Name
returns:
Folder_Name Folder_ID File_Count
folder1 1 5
folder2 2 5
where 5 is the total of all files
what Ol'Kahyaam needs is to show the
count for the files associated with
that folder - like so:
returns:
Folder_Name Folder_ID File_Count
folder1 1 3
folder2 2 2
Any thoughts?
The following works perfectly in MSSQL:
SELECT Folder_Name, Folder_Id,
(SELECT COUNT(*) FROM FILES WHERE FILES.Folder_Id = FOLDERS.Folder_Id) AS File_Count
FROM FOLDERS
GROUP BY Folder_Name
With profound esteem,
OK
*bows*
*presents gifts of gold, incence, and fine oils*
I pose this question to you:
How do I count the number of records associated with a different record?
SELECT FOLDERS.Folder_Name, FOLDERS.Folder_Id,
COUNT(FILES.Folder_Id = FOLDERS.Folder_Id) AS File_Count
FROM FOLDERS,FILES GROUP BY Folder_Name
returns:
Folder_Name Folder_ID File_Count
folder1 1 5
folder2 2 5
where 5 is the total of all files
what Ol'Kahyaam needs is to show the
count for the files associated with
that folder - like so:
returns:
Folder_Name Folder_ID File_Count
folder1 1 3
folder2 2 2
Any thoughts?
The following works perfectly in MSSQL:
SELECT Folder_Name, Folder_Id,
(SELECT COUNT(*) FROM FILES WHERE FILES.Folder_Id = FOLDERS.Folder_Id) AS File_Count
FROM FOLDERS
GROUP BY Folder_Name
With profound esteem,
OK
*bows*
*presents gifts of gold, incence, and fine oils*