Re: array fill/sort question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Snijders, Mark wrote:
hi,

no the both sollutions won't work cause:

I can't sort within a query cause subnetaddr is a varchar ("10.10.10.10")

so it will be ordere like this

10.10.10.10
100.10.10.10
60.10.10.10

and that's not good cause 60 is smaller as 100, so with the function
ip2long() i will first make an integer of it


the second array solution you gave, won't work, cause I need ALL the query results in the array, and that's the problem I can't handle....


if I would do it like you said, I can sort it, but then I have a sorted array and for each element I have to do a query again to get the other fields of the table, and that's not good (2500 rows)

so can please still somebody help me with this?



can you change the database format ?


store the address as four ints - then you can concatenate them when you need to, and sort as you wish


SELECT s_id, subnet_name, concat(subnetaddr1, '.', subnetaddr2, '.', subnetaddr3, '.', subnetaddr4) as subnetaddr ,subnetmask,dnsdomain, location, contact, ccn
FROM subnets
ORDER BY subnetaddr1, subnetaddr2, subnetaddr3, subnetaddr4;


--

Sean


-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux