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/