I am trying to build a simple private messaging system to my app. The way I have it set up each message has a thread_hash
associated with it. Messages that are related to one another have the same thread_hash
(messages that are replys to other messages all have the same thread_hash
)
I am able to run a query that selects the row that was entered last from each group (of thread_hash
's). What I want to accomplish is to return another column with the number of rows that have that particular thread_hash
without making a separate query
I've created an SQL Fiddle with the query I'm using to generate the rows: http://sqlfiddle.com/#!2/1d8bd/4
The only information I have is the user's ID. I do not have the thread_hash
, so this must be generated from the ID. I've tried playing around with some queries to generate the number of rows but my brain isn't working properly at this hour.