gpt4 book ai didi

mysql - 将值范围与另一个值范围MYSQL进行比较

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

我有一个如下表

id_indicator    id_threshold    activation_begin_value  activation_end_value

1 121 1 2
1 122 3 4
1 123 5 6
1 124 6 7
2 125 10 9
2 126 8 7
2 127 6 5
2 128 5 4

如何获取activation_begin_value和activation_end_value落入另一个阈值的详细信息。其中 6 属于 id_threshold 123 和 124,与以下两行相同,其中 5 属于两个 id_threshold。查询输出如下

id_indicator     id_threshold     activation_begin_value     activation_end_value

1 123 5 6
1 124 6 7
2 127 6 5
2 128 5 4

最佳答案

你的意思是这样的吗?

Select a.id_indicator     a.id_threshold     a.activation_begin_value     a.activation_end_value from table a
where 1=1
and a.activation_begin_value in ( select activation_end_value from table )
union
Select b.id_indicator b.id_threshold b.activation_begin_value b.activation_end_value from table b
where 1=1
and b.activation_end_value in ( select activation_begin_value from table )

关于mysql - 将值范围与另一个值范围MYSQL进行比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41267343/

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