Home  >  Article  >  Backend Development  >  求帮助,mysql如何查询最近出现的非重复人名?

求帮助,mysql如何查询最近出现的非重复人名?

WBOY
WBOYOriginal
2016-06-06 20:36:481029browse

求教,有个东西需要查询一下,就是如图,我想将周五的人名与前4天做对比,如果不重复的话,就显示出来。请问这个mysql语句该怎么写呢?
我希望得到的结果是皮特和玛丽。但是不知道这个mysql语句该怎么写。谢谢
求帮助,mysql如何查询最近出现的非重复人名?

回复内容:

求教,有个东西需要查询一下,就是如图,我想将周五的人名与前4天做对比,如果不重复的话,就显示出来。请问这个mysql语句该怎么写呢?
我希望得到的结果是皮特和玛丽。但是不知道这个mysql语句该怎么写。谢谢
求帮助,mysql如何查询最近出现的非重复人名?

<code>sql</code><code>SELECT
NAME
FROM
    tbl
WHERE
    date = 'Fri'
AND NAME NOT IN(
    SELECT
        NAME
    FROM
        tbl
    WHERE
        date IN('Mon', 'Tue', 'Wed', 'Thu')
)
</code>

笨办法是这样子的,当用户数据很多的时候效率会有问题。

取出来这两段数据,做下交集

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn