Archive for October 24th, 2006

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


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

Reader/Customer Feedback

Harvey Recommends

Accolades

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  

Posts by Month

Posts by Category