Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.