Having a field called COUNT could present problems since COUNT is a FUNCTION used by MOST SQL type servers.
If you wanted to know if you have “Exceeded” the COUNT you can do a query such as
SELECT COUNT(studnetnumber) FROM students, classes
WHERE classes.session = 1 AND classes.time = 9 AND students.studentnumber = colname2 AND classes.grade1 = students.grade or classes.grade2 = students.grade or classes.grade3 = students.grade
This will return a SINGLE value which is HOW MANY times a record appears matching the WHERE clause.
You can then determine, based on that result, what to do next.
As stated above, you should probably avoid using names that match functions as database, table, or column names such as COUNT, SUM, GROUP, ORDER, etc… as well as the “RESERVED” Words (see http://dev.mysql.com/doc/refman/4.1/en/ … words.html ). Instead consider a variation of these words such as CLASSCOUNT, CLASSSUM, GROUPNAME, ORDEREDITEMS, etc…
Hope this helps.