gpt4 book ai didi

mysql - 在一个选择中查找 'friend of a friend' 关系(SUBSELECT 和/或 JOIN)

转载 作者:行者123 更新时间:2023-11-29 00:26:43 26 4
gpt4 key购买 nike

<分区>

我有一个“关系”矩阵,如:

+---------+------------+------------+------------+------------+------------+| name    | Albert     | Bob        | Charles    | Dale       | Ethan      |+---------+------------+------------+------------+------------+------------+| Albert  |            |    0       |    1       |    1       |   -1       || Bob     |            |            |    1       |   -1       |    1       || Charles |            |            |            |    0       |    1       || Dale    |            |            |            |            |    0       || Ethan   |            |            |            |            |            |+---------+------------+------------+------------+------------+------------+ 0 means they don't know each other 1 means they like each other-1 means they don't like each other

现在,我想输入两个名字并获得共同认识的人的数量,并通过将“喜欢”相加(最好在一个 SELECT 中)来“推测”他们的关系。


以 Charles 和 Dale 这对为例:

Charles knows Albert and Bob, who also know Dale.
The relationship between Charles and Dale would probably be friendly since Charles likes Albert (+1) who likes Dale (+1) and Charles likes Bob (+1) though Bob does not like Dale (-1).

So, the output would be 2 mutual known people and a 'speculation' of +3.


我无法理解功能性子选择查询,再加上矩阵只填充了一半这一事实似乎使它变得更加复杂(有时名称是第一个索引,有时是第二个索引)。

有人可以帮我制定一个有用的查询吗?

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