Sorry for the simple question, but I didn't know the proper way to word it to get useful results. I was wondering if there was a function in MySQL that supports a "has all" relationship. The term that I think I'm referring to is set division (when I look up division in the manual pages, I only see precision mathematical division in MySQL). So, for example, if I had a relation of students and courses, I might want to retrieve a list of courses in which ALL of the students are taking (perhaps, the course ID number appears under each student, or something similar). Does my question make sense? I can come up with a开发者_开发知识库 different query to get the job done, but it would be really nice if I could simplify it all with a simple built in function, you know?
No there isn't. See Divided We Stand: The SQL of Relational Division for a good round up of approaches. The article is SQL Server centric but the same 2 approaches of GROUP BY ... HAVING COUNT
or double NOT EXISTS
still work.
For exact relational division (with no remainder) GROUP_CONCAT
could come in handy though.
精彩评论