I'm not sure what you are trying to do in the code.
What is parent_id? Is it the id of the thread that the post belongs to? If that's the case, you seem to be returning the first match, which may not be what you want.
In any case you can improve this quite a bit by changing the SELECT statement to return just the parent_id since that's what you seem to be interested in.
like
SELECT parent_id FROM cmsteam_forum_posts
It'll help if you can describe more as to how your database is organized and what operation you are trying to do.
Thanks ...