Unanswered: [SOLVED] Select Query on multiple tables with count(*)
First post in this forum, maybe I can get help here! This problem is to complex for other forums... (but still not that complex ig)
Fixed the problem myself... after HOURS of trying
Used the following horribly easy query:
count(user_classes.user_ID_int_FK) as students
left join user_classes
on user_classes.class_ID_FK = classes.class_ID
group by class_ID
The List I want to get should look like this:
It shows all the classes with ID, name and how many students are in that class.
Which it does already... I used the following query:
count(*) as students
classes.class_ID = user_classes.class_ID_FK
GROUP BY class_ID;
There is one problem: I also want to get those classes that have 0 students participating as well in that list! But I dont get it to work cause of the "classes.class_ID = user_classes.class_ID_FK"-clause, which only works if there are students assigned to that class.
So how do I do that? Does it require 2 Queries?? I really have no idea... googled it for a bit but couldnt get a result out of that!