I have a table with columns artist, title, album and other columns for dates, ip etc
now i want to display unique artist title and album in a row
like say,
artist , album, title
a , b , c
a , b , c
d , e , f
a , b , d
then it must display
a,b,c
d,e,f
a,b,d
how?
You can use the
DISTINCTkeyword.But it doesn’t seem as though your design is normalised if these are being repeated in each row.
(Edit after comments.) It seems you need other columns but you don’t care which of the possible matching values are shown in these. In that case you can use
GROUP BYAs far as I understand in MySQL if you don’t specify selected columns in theGROUP BYyou would get this but it’s completely invalid in all other RDBMSs.In other RDBMSs you would need to wrap these in an aggregate. e.g.
The values returned could very well be from different rows with the above. To avoid this you would use a
greatest-n-per-groupquery