I managed to solve the problem. Rather than trying to do some out-of-my-depth mysql query I added another column to "thread" called "lastupdate". Then each time a new comment was made inserted the current timestamp into the thread table as well as the date column on the comments table.
I'm glad you sorted it. Although when you have queries of this nature that are quite intensive, you should take a look at using MySQL views. I realise it's supposed to be a simple forum package, however, views will add to the efficiency of such queries.
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.