mysql中的关系划分没有聚集功能? [英] Relational division in mysql without aggregrate functions?

查看:79
本文介绍了mysql中的关系划分没有聚集功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在mysql中使用存在或不存在的地方实现一个简单的关系划分,我不想使用任何聚集函数,也不想使用where in或where not in子句.我正试图以相同的方式编写关系代数和关系演算查询,所以如果我这样做,将很容易.

I want to implement a simple relational division in mysql with where exists or where not exists.I don't want to use any of the aggregrate functions and also don't want to use where in or where not in clauses.I am trying to write relational algebra and relational calculus queries for the same so it would be easy if I do it this way.

例如:

GID  PID  TEAM

101   1    X

201   2    X

301   3    X

101   4    Y

201   5    Y

101   6    Z

答案是GID,TEAM/GID,它以X作为答案.我想知道如何实现存在或不存在的mysql.

The answer is GID,TEAM/GID which gives X as the answer.I want to know how to implement this is mysql with where exists or not exists.

推荐答案

您需要的是简单的codd的关系划分.

What you need is simple codd's relational division.

select distinct p.team from player p 
where not exists
(select * from player p1 
where not exists
(select * from player p2 
where 
p.team=p2.team 
and 
p2.gid=p1.gid))

这篇关于mysql中的关系划分没有聚集功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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