I am currently trying to make sense of using two tables with the INNER JOIN statement. It could very well be that there is different syntax I should be using.
Here is the table structures:
"Groups"
groupID
groupTitle
"Elements"
elementID
elementTitle
groupID
Both groupID in the Groups table and elementID in the Elements table are both primary keys with auto increment. groupID in the Elements table obviously refers to a key in Groups.
I am basically trying to pull records from the Groups table and, at the same time, get a count of how many Element records belong to that group. Here is my SQL
$SQL = "SELECT
FM_Groups.groupID,
FM_Groups.groupTitle,
COUNT(FM_Elements.elementID) AS elementCount
FROM
FM_Groups
INNER JOIN
FM_Elements
ON
FM_Elements.groupID=FM_Groups.groupID
GROUP BY
FM_Groups.groupTitle";
This works just fine if there are elements assigned to a group. However, if there are no elements that have a groupID of say, 5, then that group won't be retrieved either.
What other syntax could I use to pull up all groups, regardless of whether or not any elements are assigned to it?
Hope this makes sense, and thanks in advance.