在Delphi中筛选MySQL结果

问题描述:

我有一个问题,对我的一个家庭作业有一定的要求。我需要拿到学生名单,并打印出所有学生的信用时间为12或更多。学分小时存储在单独的表中,并通过基本的第三张表
,学生表,具有小时的班级表以及将学生ID与课程ID匹配的注册表

I'm having an issue with a certain requirement to one of my Homework Assignments. I am required to take a list of students and print out all of the students with credit hours of 12 or more. The Credit hours are stored in a separate table, and referenced through a third table basically, a students table, a classes table with hours, and an enrolled table matching student id to Course id

我使用SUM聚合从表中按名字分组,并且所有工作都很好,但我不太明白如何过滤掉人少于12小时,因为SQL不

I used a SUM aggregate grouped by First name from the tables and that all works great, but I don't quite understand how to filter out the people with less than 12 hours, since the SQL doesn't know how many hours each person is taking until it's done with the query.

我的字符串看起来像这样

my string looks like this

'SELECT Students.Fname, SUM(Classes.Crhrs) AS Credits 
FROM Students, Classes, Enrolled 
WHERE Students.ID = Enrolled.StudentID AND Classes.ID = Enrolled.CourseID 
GROUP BY Students.Fname;'






它工作正常,并显示在Delphi项目中的网格,但我不知道从哪里去过滤结果,因为每个查询运行删除以前。


It works fine and shows the grid in the Delphi Project, but I don't know where to go from here to filter the results, since each query run deletes the previous.

由于是家庭作业练习,我将给出一个非常简短的答案:查找 HAVING

Since it's a homework exercise, I'm going to give a very short answer: look up the documentation for HAVING.