xwishmasterx Posted January 27, 2015 Share Posted January 27, 2015 Hello. I'm having some issues with a select statement containing ABS(). Here's the select query: "SELECT gadenavn, husnr, ABS(husnr - $husnr) AS husnr_range, postnr,db, shaping, dsl_node, ctr_node, db_ctr_luftlinje, bynavn FROM `TABLE 1`, Post_numre WHERE `postnr`=`postnummer` AND `gadenavn`=`$vejnavn` AND `postnr`=`$postnr` AND `husnr`>0 ORDER BY husnr_range ASC LIMIT 5" Now lets asume my variable "$husnr" is a value of 15. In my table I have the values for coulmn "husnr": 13,12,11,10,9 What really bugs me is the outcome doing af simple "while loop" is returning the values 12,11,10,9. What happened to 13?! printing the "husnr_range" values shows "3,4,5,6". What puzzles is the row missing, as I only get 4 results, with a "LIMIT 5". Can anyone explain why the last resulst isn't included? Quote Link to comment https://forums.phpfreaks.com/topic/294248-select-abs-not-returning-expected-result/ Share on other sites More sharing options...
requinix Posted January 27, 2015 Share Posted January 27, 2015 Is your husnr column UNSIGNED? Quote Link to comment https://forums.phpfreaks.com/topic/294248-select-abs-not-returning-expected-result/#findComment-1504297 Share on other sites More sharing options...
mac_gyver Posted January 27, 2015 Share Posted January 27, 2015 i'm going to guess that in your php code, you are fetching and not using the first row from the result set, before the start of a loop that gets the remaining 4 rows from the result set. Quote Link to comment https://forums.phpfreaks.com/topic/294248-select-abs-not-returning-expected-result/#findComment-1504298 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.