- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
假设我有一个如下所示的 friend 和事件表
FriendsTable {
user1_ID
user2_ID
}
Events Table {
event_ID
user_ID
}
在我的 friend 表中,如果 user1 和 user2 是 friend ,我只将它存储在我的数据库中一次,其中 user1 < user2。所以 (1,2) 会被发现,但 (2,1) 不会。
我正在尝试找出一种方法来返回不是 friend 但按降序参加相同事件的用户。例如,
Events_Table{
1, 1 //user1 attended event1
1, 2 //user2 also attended event1
3, 1 //user1 attended event 2
3, 3 //user 3 attended event 3
4, 1 //user1 attended event 4
4, 3 //user3 attended event 4
3, 5 // user 5 attended event 3
}
User_table{
1, 2 //user1 is friends with user 2
}
因此,由于用户 1 和 3 不是 friend 但一起参加了事件 3 和 4,而用户 1 和 5 不是 friend 但参加了事件 3结果将是 (1,3) 和 (1,5),因为用户 1 和用户 3 有更多类似的参加事件。
我的想法
我不想把这篇文章写得太长,但我想先用它来寻找不是 friend 的 friend
select * from (select distinct f1.user1_id as user1, f2.user2_id as
user2 from FriendsTable as f1, FriendsTable as f2 where
f1.user1_id < f2.user2_id MINUS select * from FriendsTable
然后以某种方式将它加入事件表...
最佳答案
您可以使用基于自左连接的动态表
select * from
events where event_ID in (
select distintc e.event_ID
from events as e
left join FriendsTable as f1 on f1.user1_id = e.user_ID
left join FriendsTable as f2 on f2.user1_id = e.user_ID
where f1.user_ID is null
or f2.user_ID is null
)
order by events, user_ID;
关于mysql - 返回不是 friend 但一起参加最多事件的用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40007926/
很荣幸本周六被邀请到百度“英雄汇”移动开发者沙龙,在此次会议中,看到不少的大牛分享不错的干货,今天把我在会议中所听到的内容给大家分享一下。 数据价值 看起来就是广告的会议,其实也给我们统计出很多
我试图部分消耗Kotlin中的序列,以将其拆分。 fun main() { val seq = listOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9).asSequence(
我正在处理一个查询,试图找出您当前的连续出勤记录。所以换句话说,人 1 参加了最后 5 场事件,人 2 参加了最后 6 场事件,等等。我为此获得的数据文件非常简单: Event Number - Un
我找不到只参与 rdd 的方法. take看起来很有希望,但它返回 list而不是 rdd .我当然可以将其转换为 rdd ,但这似乎既浪费又丑陋。 my_rdd = sc.textFile("my
我目前正在从事学术目的的自然语言处理工作,我想获取 Microsoft Research Sentence Completion Challenge 数据集。 不幸的是,它似乎不再可用 on Micr
我正在尝试让所有参加特定 Activity 的 Facebook 好友。 select uid, rsvp_status from event_member where uid IN (SELECT
我们的任务是编写一段代码来猜测 0 到 100 之间的一个 secret 数字。这是我的一段代码: low = 0 mid = 50 high = 100 secretnum = "Is your s
下学期我将使用我的 MacBook Pro 参加基于 Python 的计算机科学类(class)。它将以定制设计为中心 package对于这个类。问题是这个软件包是由 Microsoft Resear
我是一名优秀的程序员,十分优秀!