MySQL - Select Entire DB Row With One Field DISTINCT

October 24th, 2006

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;

Entry Filed under: PHP/MySQL Snippets, Signposts

Bookmark This: del.icio.us:MySQL - Select Entire DB Row With One Field DISTINCT digg:MySQL - Select Entire DB Row With One Field DISTINCT newsvine:MySQL - Select Entire DB Row With One Field DISTINCT blinklist:MySQL - Select Entire DB Row With One Field DISTINCT furl:MySQL - Select Entire DB Row With One Field DISTINCT reddit:MySQL - Select Entire DB Row With One Field DISTINCT Y!:MySQL - Select Entire DB Row With One Field DISTINCT


About Harvey Ramer

CSS Web design, e-commerce Web design, and internet marketing issues from the desk of Harvey A. Ramer at Design Delineations.

View Harvey Ramer's profile on LinkedIn

Harvey Recommends

Design Notes: A CSS Web Designer’s Blog at Blogged

Calendar

October 2006
M T W T F S S
« Sep   Nov »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Most Recent Posts