RE: Array sorting question...

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

 



NIPP, SCOTT V (SBCSI) wrote:
> 	I am trying to populate an array from a MySQL database.  I think I
> have the code correct to populate the array, but I need to somehow
> sort the array eliminating duplicate values.  I think I can loop
> through the array doing a comparison and building a new array by
> discarding the value if it is a duplicate, but I was not sure if
> there was a more efficient way of doing this.

You can ask for only unique values to be returned in the database result.

Try something like this:

$sql = "SELECT UNIQUE username FROM table WHERE where_clause ORDER BY
username";

Katie Dewees
Web Developer/PHP Programmer
kdewees@xxxxxxxxxxxxx
http://www.evans-young.com

-- 
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