我有这个SQL表:
GAME
ID PLAYER MIN_VALUE_1 MIN_VALUE_2
1 John 1.2 3
2 Paul 1.4 3.2
3 Henry 1.6 3.4
4 Tom 2.1 3.6
PREDICTIONS
ID_GAME HOUSE VALUE_1 VALUE_2
1 house_a 1.5 3
1 house_b 1 2.9
2 house_a 1.2 3.1
2 house_b 1.4 3.6
2 house_c 1.5 4
3 house_a 1.5 4
3 house_b 1.7 4.2
3 house_c 1.8 4
3 house_d 1.9 4.3
4 house_b 1.6 3.1
4 house_d 1.9 3
我有两个选择:
有了这个:
SELECT *
FROM game m
INNER JOIN predictions p ON m.id = p.id_game
WHERE p.value_1 >= m.min_value_1 OR p.value_2 >= m.min_value_2
我获取了VALUE_1> = MIN_VALUE_1或VALUE_2> = MIN_VALUE_2
的所有行ID_GAME HOUSE VALUE_1 VALUE_2 MIN_VALUE_1 MIN_VALUE_2
1 house_a 1.5 3 1.2 3
2 house_b 1.4 3.6 1.4 3.2
2 house_c 1.5 4 1.4 3.2
3 house_a 1.5 4 1.6 3.4
3 house_b 1.7 4.2 1.6 3.4
3 house_c 1.8 4 1.6 3.4
3 house_d 1.9 4.3 1.6 3.4
并查询:
SELECT *
FROM game m
INNER JOIN predictions p ON m.id = p.id_game
WHERE p.value_1 < m.min_value_1 AND p.value_2 < m.min_value_2
我获得VALUE_1&lt;所有行MIN_VALUE_1和VALUE_2&lt; MIN_VALUE_2
ID_GAME HOUSE VALUE_1 VALUE_2 MIN_VALUE_1 MIN_VALUE_2
1 house_b 1 2.9 1.2 3
2 house_a 1.2 3.1 1.4 3.2
4 house_b 1.6 3.1 2.1 3.6
4 house_d 1.9 3 2.1 3.6
但我需要获取两个查询的所有行,但相同的ID_GAME 。我需要这个:
ID_GAME HOUSE VALUE_1 VALUE_2 MIN_VALUE_1 MIN_VALUE_2
1 house_a 1.5 3 1.2 3
1 house_b 1 2.9 1.2 3
2 house_a 1.2 3.1 1.4 3.2
2 house_b 1.4 3.6 1.4 3.2
2 house_c 1.5 4 1.4 3.2
3 house_a 1.5 4 1.6 3.4
3 house_b 1.7 4.2 1.6 3.4
3 house_c 1.8 4 1.6 3.4
3 house_d 1.9 4.3 1.6 3.4
答案 0 :(得分:1)
我认为你应该删除where
条款
select * from predictions p INNER JOIN game m ON p.id_game = m.id WHERE
p.value_1 < m.min_value_1 AND p.value_2 < m.min_value_2;
答案 1 :(得分:0)
最后我找到了一个解决方案(我不知道是否理想的解决方案):
ngOnChanges(changes: any): void {
console.log('change', changes.skills.currentValue);
}