Mysql SELECT DISTINCT VALUES separated by a comma

I have a  MySQL table, with a field named 'actors'.
In this field are found names separated by a comma.

What would be the better method to SELECT DISTINCT actors ?...
Put everything in an array and explode it then sort it? Or woud there be a simpler Query to do it?
Thank you
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Cornelia YoderArtistCommented:
SELECT DISTINCT works on the entire field, so your best bet is to retrieve the field and then use php to get your distinct values.  Explode() is a good approach, and then you could use array_unique to remove duplicate values.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rotemwebAuthor Commented:
So your solution would be:

- SELECT actors FROM mytable
- Then put all values in a variable (wouldn't it be too long? the table is not too big- yet)
- Explode the variable
- Use array_unique to remove duplicate

...and use that array

Is that it?  
No other solution?

Cornelia YoderArtistCommented:
That seems like the easiest method to me.  You could normalize your database so that you have only actor name per field, and then use MySQL Select Distinct, but if you must have a variable number of comma-separated names in the table, then I don't see any better choice.
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

rotemwebAuthor Commented:
Ok, thanks. I thought, maybe a special unknown Query on MySQL ;o)
But i doubted it.

Cheers :)
Cornelia YoderArtistCommented:
Thank you for the points, but I am curious (for the future) what more I could have done to earn a grade of A?
rotemwebAuthor Commented:
Well, it is a matter of how intricate is the question and the answer.
 I basically suggested the answer, and you confirmed it.
 If, thanks to your answer  I had accessed to the best solution possible, something I hadn't imagined (it happened to me here many times) I would have rated 'excellent'.
( It was very good though )

But it is not due to your knowledge (that i don't question at all);  just to the question / range of answers.  
Cornelia YoderArtistCommented:
Well, for the future, please keep in mind that sometimes the correct answer is -- there isn't a way.  

While it's true that I confirmed your thought, and added the array_unique function rather than your suggested sorting, it's not my fault that there wasn't a slick solution that you were hoping for.
rotemwebAuthor Commented:
A rating is subjective.If not, you would rate yourself.
"Flagrant injustice" doesn't apply here.
 So please let's close that topic, it is of poor interest.
Cornelia YoderArtistCommented:
OK, if that's the way you want to react to my suggestion for future behavior, see ya around, not.
rotemwebAuthor Commented:
Ok, you're right.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.