如何在mysql中的列之间搜索 [英] How to search between columns in mysql
本文介绍了如何在mysql中的列之间搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两列存储值(数字),如何选择给定数字在两列值之间的位置?
i have two columns that store values(numbers), how do i select where my given number is between the values in the two columns?
示例
`id | col1 | col2`
`1 | 20 | 50`
`2 | 200 | 400`
`3 | 500 | 650`
如果我的值为25,我该如何选择介于25和25之间的记录(在这种情况下将是第1行)
If I have a value of 25, how can i select records where the value of 25 is between them which in this case would be row 1
推荐答案
select * from mytable where 25 between col1 and col2;
这篇关于如何在mysql中的列之间搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文