gpt4 book ai didi

mysql - 如何选择具有一个不同值和多个重复值的行?

转载 作者:行者123 更新时间:2023-11-28 23:40:32 24 4
gpt4 key购买 nike

我有一个这样的表:

// mytable
+----+--------------------------+---------------+-----------------+
| id | Email | IP | cookies |
+----+--------------------------+---------------+-----------------+
| 1 | jack.123@gmail.com | 172.95.65.7 | 5c6ffbdd40d95 |
| 2 | ali.mngvv@yahoo.com | 84.15.2.4 | 26b73a21e63c3 |
| 3 | redhat1931@gmail.com | 124.54.32.1 | e0e904b73a2fe |
| 4 | peter_1998@gmail.com | 172.95.65.7 | 5c6ffbdd40d95 |
| 5 | b.batman@ymail.com | 56.23.41.3 | b23a51a63edf4 |
| 6 | ali.mngvv@yahoo.com | 84.15.2.4 | 26b73a21e63c3 |
+----+--------------------------+---------------+-----------------+

现在我想同时选择第一行和第四行。因为他们有相同的IP、相同的Cookies和不同的Email。我怎样才能选择它们?

我想要这个输出:

// newmytable
+----+--------------------------+---------------+-----------------+
| id | Email | IP | cookies |
+----+--------------------------+---------------+-----------------+
| 1 | jack.123@gmail.com | 172.95.65.7 | 5c6ffbdd40d95 |
| 4 | peter_1998@gmail.com | 172.95.65.7 | 5c6ffbdd40d95 |
+----+--------------------------+---------------+-----------------+

最佳答案

你可以使用exists作为

select m1.* from mytable m1
where exists (
select 1 from mytable m2
where
m1.Email <> m2.Email
and m1.IP = m2.IP
and m1.cookies = m2.cookies
)

关于mysql - 如何选择具有一个不同值和多个重复值的行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34528636/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com