Php 如何在select语句中使用“between”
这本应是一个简单的解决方案,但我无法预测我的未来。 我有一张桌子 这是我的疑问Php 如何在select语句中使用“between”,php,mysql,Php,Mysql,这本应是一个简单的解决方案,但我无法预测我的未来。 我有一张桌子 这是我的疑问 $salary=2000; select deductions from nhif_tbl where to_end <=$salary and start_from >= $salary; 查询返回null。 我的问题是如何修改查询,以便在这种情况下获得正确的扣减额“60”您的“终点”应该比“起点”多999 像这样 select deductions from nhif_tbl where t
$salary=2000;
select deductions from nhif_tbl where to_end <=$salary and start_from >= $salary;
查询返回null。
我的问题是如何修改查询,以便在这种情况下获得正确的扣减额“60”您的“终点”应该比“起点”多999
像这样
select deductions from nhif_tbl where to_end >=$salary and start_from <= $salary;
那很明显,试着扭转这种状况
....where to_end >=$salary and start_from <= $salary;
让我们做一些条件分析
当条件开始时,不应该从nhif中选择扣除额,从哪里结束>=$salary和start两个条件之间的距离只有499。如果salary是1000呢?是的,逻辑不应该是这样的。这个解决方案首先出现在我的脑海中,然后发布!改变。。。
select deductions from nhif_tbl where to_end >=$salary and start_from <= $salary;
....where to_end >=$salary and start_from <= $salary;