Showing a db value only once per output. Possible?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
doffer
Forum Newbie
Posts: 6
Joined: Mon Jul 18, 2005 10:56 pm

Showing a db value only once per output. Possible?

Post by doffer »

I have a table which stores information for my media review system, and that table have ten fields..

Release data, title, artist and a few others...

The artist field contains the artist/performer name. I want to output a list of all artists starting with a specific letter.. That could be done running the query;

Code: Select all

SELECT *
FROM `cd`
WHERE `artist` LIKE 'b%'
ORDER BY `artist` ASC
LIMIT 0 , 100
But then I'll get all the rows having an artist starting with the letter, in this case, b. I want it to only show the artist once. If someone could tell me how to strip out the artists appearing more than once, it would be splendid :D

I have only written php for a week or so, and have allready written my own mini-"CMS" located at http://doffer.net/samler/. *proud newbie* :)
doffer
Forum Newbie
Posts: 6
Joined: Mon Jul 18, 2005 10:56 pm

Solved!

Post by doffer »

Solved the problem my self... I altered the query to:

Code: Select all

SELECT DISTINCT `artist`
FROM `cd`
WHERE `artist` LIKE 'b%'
LIMIT 0 , 30
A lot more fun solving own problems :)

Have a nice day!
Post Reply