gpt4 book ai didi

mysql - sql中如何使用between和大于

转载 作者:行者123 更新时间:2023-11-29 22:05:15 25 4
gpt4 key购买 nike

table name:tax
slab1 slab2 tax
0 10000 0
10001 50000 10
50001 100000 20
100001 0 30

这里0代表无穷大。

我的表是这样的。我要找到60000的税。我不知道如何在sql中一起使用Between和大于。

I tried like this:
$query="SELECT * FROM taxsettings
where $liable2 between tax.slab1 and tax.slab2
or $liable2 > tax.slab1";

$liable2 是金额。 任何人都可以说出如何将无穷大值插入数据库表

最佳答案

尝试这个查询

"SELECT * FROM taxsettings 
where $liable2 between case when tax.slab1=0 then $liable2 else tax.slab1 end and case when tax.slab2 =0 then $liable2 else tax.slab2 end;"

关于mysql - sql中如何使用between和大于,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32200812/

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