是否存在“全部出现"? (设置除法?)MySQL内置的操作? [英] Is there a "appears in all" (set division?) operation built into MySQL?

查看:82
本文介绍了是否存在“全部出现"? (设置除法?)MySQL内置的操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉这个简单的问题,但是我不知道正确的措词方式来获得有用的结果.我想知道MySQL中是否有支持全部"关系的函数.我指的是设置除法(当我在手册页中查找除法时,我只看到MySQL中的精确数学除法).因此,例如,如果我与学生和课程有联系,我可能想检索所有学生都参加的课程列表(也许,课程ID号出现在每个学生的下方,或类似的名称).我的问题有意义吗?我可以提出一个不同的查询来完成工作,但是如果我可以使用一个简单的内置函数来简化所有工作,那将是非常好的.

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?

推荐答案

没有.参见已划分我们的立场:关系部门的SQL 提供了很好的方法综述.本文以SQL Server为中心,但GROUP BY ... HAVING COUNT或double NOT EXISTS的相同2种方法仍然有效.

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.

对于精确的关系划分(没有余数),GROUP_CONCAT可能会派上用场.

For exact relational division (with no remainder) GROUP_CONCAT could come in handy though.

这篇关于是否存在“全部出现"? (设置除法?)MySQL内置的操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆