No need to do any loops, a simple JOIN should work for you:
SELECT * FROM CategoryTable CT LEFT JOIN TextTable TT ON CT.Category = TT.Category
I used LEFT JOIN if you want to return rows from the Category table that do not have a matching match in the Text table.
If you only need matching records, just replace LEFT JOIN with INNER JOIN .
source share