MySQL - Select Entire DB Row With One Field DISTINCT
Yesterday, I needed to select a list of albums from a database searching on a list of instruments the artists played. This worked fine as long as there were not multiple artists playing the same instrument, in which case, the album was repeated in my list for each instance of the selected instrument.
To fix the problem, I needed to select that album as DISTINCT even though my search string was repeated. I found a code snippet that I modified to achieve this on the MySQL site here:
the whole query for retrieving an array of rows with one field distinct (no repeats) is:
select *, count(FIELD) from TABLE group by FIELD having count(FIELD)>=1;
October 24th, 2006