Page 1 of 1

Mysql_query into an array

Posted: Tue Jul 17, 2007 7:52 pm
by ankhmor
Problem: How can I put the whole mysql_query into an array that I can use array_unique on?

Posted: Tue Jul 17, 2007 7:55 pm
by John Cartwright
Better yet, why not

Code: Select all

.. GROUP BY `fieldname`
in your sql statement the field you want unique?

Posted: Tue Jul 17, 2007 8:06 pm
by feyd
or DISTINCT.

Posted: Tue Jul 17, 2007 8:32 pm
by boo
I think with distinct all of the fields that are returned would need to match rather than just 1 or 2 of the fields, but if that is what you are looking for then distinct would be the way to go. No reason to send back something you are not going to use.

Posted: Tue Jul 17, 2007 8:36 pm
by feyd
boo wrote:I think with distinct all of the fields that are returned would need to match rather than just 1 or 2 of the fields, but if that is what you are looking for then distinct would be the way to go. No reason to send back something you are not going to use.
It would be the same result as array_unique() with a lot of cruft removed, so I'm pretty sure ~ankhmor is looking for it. :)

Posted: Tue Jul 17, 2007 8:43 pm
by boo
feyd wrote:It would be the same result as array_unique() with a lot of cruft removed, so I'm pretty sure ~ankhmor is looking for it. :)
You are right just looked it up in the manual after I posted since I was not sure if array_unique() looked at the whole string value.

Posted: Wed Jul 18, 2007 2:40 pm
by ankhmor
thanks guys. Highly apreciated