Jump to content

Select ABS() not returning expected result


xwishmasterx

Recommended Posts

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.