i have a problme with a search im trying to do. i have a database with many fields, but one of the fields isn't necesarily unique in the sense that what is in that field may be the same for many entries. how can i do a search that show that entry in the field only once? lets say the field is cd name. so there may be one same cd name for many songs. how can i do so that when i search for cd name it only shows up once? instead of one for every song that is in that cd?
select cd_name from YOURTABLE where xxxx GROUP BY cd_name;
-- Jason
that'll show me only al the cds matching the query only once?
Or..
SELECT DISTINCT cd_name FROM cdtable
Vex is right...select DISTINCT is better....
Use the GROUP BY if you also need to get a count of the number matching your search.
But yes, that will only give you one item per match.
Yay for me.. 😃