There is a problem with your design. You should not store categories in a string in MySQL.
You should store categories in a new table, with a many-to-many table linking the two:
Once you have a many-to-many table linking your Articles to your Categories, you can retrieve articles based on Categories, and rate how well the match the required keywords.
SELECT A.*, L.Relevance
FROM Article AS A
INNER JOIN
(
SELECT AC.ArticleID, COUNT(AC.CategoryID) AS Relevance
FROM ArticleCategory AS AC
INNER JOIN Category AS C
ON AC.CategoryID = C.CategoryID
WHERE C.Name IN ('Cat','Dog','Donkey','Chicken')
GROUP BY AC.ArticleID
) AS L
ON A.ArticleID = L.ArticleID
ORDER BY L.Relevance DESC, Name
You can see an example in SQLFiddle.
You can also get more information here:
- https://stackoverflow.com/a/14683541/1005039
- https://www.simple-talk.com/sql/t-sql-programming/divided-we-stand-the-sql-of-relational-division/
An alternative is to use the full text search functions in MySQL. More information here: