boclair@xxxxxxxxxxx wrote:
I have a table with between 100k and 200k rows. One field, `names`, is
populated, in each row, with an imploded array of up to 4 names.
I require to create a list of names, without repeats, of all the names
in `names` field to use in an html form.
Any advise would be appreciated. I have no ideas on how to start.
The best option would be to normalise the data by breaking the names out
to a separate table. However, if that's not feasible my suggestion is
similar to that itoctopus sent, but a bit more memory efficient.
Inside the loop getting the records, do the following...
foreach (explode(',', $single_result['name']) as $name)
$arr_all_names[$name] = 1;
Then after the loop, to get an array of the names...
$arr_all_names = array_keys($arr_all_names);
-Stut
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php