beboo002 Posted May 5, 2008 Share Posted May 5, 2008 Hello all Mysql Query not Fetch right result My table looks like id subid mincost maxcost mode mode1 1 0 1 4000 1 rent 2 0 4001 6000 2 rent 3 0 6001 10000 3 rent 4 0 10001 15000 4 rent 5 0 15001 20000 5 rent 6 0 20001 25000 6 rent 7 0 25001 40000 7 rent 8 0 40001 70000 8 rent 9 0 70001 100000 9 rent 10 0 100001 150000 10 rent 11 0 150001 200000 11 rent 12 0 200001 500000 12 rent 13 0 500001 1000000 13 rent 14 0 Above 10+ lacs Above 10+ lacs 14 rent 16 1 1 4000 1 rent 17 2 4001 6000 2 rent 18 3 6001 10000 3 rent 19 4 10001 15000 4 rent 20 5 15001 20000 5 rent 21 6 20001 25000 6 rent 22 7 25001 40000 7 rent 23 8 40001 70000 8 rent 24 9 70001 100000 9 rent 25 10 100001 150000 10 rent 26 11 150001 200000 11 rent 27 12 200001 500000 12 rent 28 13 500001 1000000 13 rent 29 14 Above 10+ lacs Above 10+ lacs 14 rent Now I fire a query which is search subid select subid from pay_code where mincost<'300000' and mode1='rent' order by subid desc limit 1; Its gives subid=7, which is wrong it gives subid=12 Thanks beboo Link to comment https://forums.phpfreaks.com/topic/104169-mysql-query-not-fetch-right-result/ Share on other sites More sharing options...
psychowolvesbane Posted May 5, 2008 Share Posted May 5, 2008 select subid from pay_code where mincost<'300000' and mode1='rent' order by subid desc limit 1; You have too many 0's, if you want 7 you only need 30K not 300K. Link to comment https://forums.phpfreaks.com/topic/104169-mysql-query-not-fetch-right-result/#findComment-533298 Share on other sites More sharing options...
beboo002 Posted May 5, 2008 Author Share Posted May 5, 2008 Thanks for reply select subid from pay_code where mincost<'300000' and mode1='rent' order by subid desc limit 1; here the main problem is that query is not Efficient to get result but here i want subid 12 becouse 300k between 200k to 500k range Link to comment https://forums.phpfreaks.com/topic/104169-mysql-query-not-fetch-right-result/#findComment-533299 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.