Reputation: 329
This is supposed to be an easy solution but i can't my ahead around it.
I have a table
Here is a my query
$salary=2000;
select deductions from nhif_tbl where to_end <=$salary and start_from >= $salary;
The query returns null. My question how do i modify the query in order to get correct deductions in this case '60'
Upvotes: 0
Views: 52
Reputation: 3821
Your to_end
should be 999 more than the start_from
$salary=2000;
select deductions from nhif_tbl
where to_end >=$salary and start_from <= $salary;
Upvotes: 0
Reputation: 199
that's obvious try to revers the condition!
....where to_end >=$salary and start_from <= $salary;
let's do some analyses for the conditions when it's starts the condition to_ens<=2000 it's grabs the first and the second line, and when jumps next to the second condition start_from >= 2000... well you got my point!
Upvotes: 0
Reputation: 13484
Like this
select deductions from nhif_tbl where to_end >=$salary and start_from <= $salary;
Upvotes: 0
Reputation: 16464
select deductions from nhif_tbl where to_end >=$salary and start_from <= $salary;
Upvotes: 1