Thanks for the replies guys!!
I think i would like to go with djjjozsi's way of just using 2 tables -- it seems a good idea to cut down on the sql queries.
However, what i am trying to do is more like a forum, then emails, so there would not a field like "userid_to", so i'm kind of lost 🙁
I have cut down my tables to the following:
users:
ID Name
1 Bob
2 Jack
3 Paul
4 Mick
Message:
ID TopicID UserID MessageText isReply
1 1 1 Hello 0
2 1 1 Hello Again 1
3 1 2 Im Jack 1
4 1 4 Im Mic 1
5 1 3 Im New 0
6 1 1 Another Msg 5
7 1 2 And Again 5
8 2 2 New Area 0
9 2 4 Great 8
I have been able to do the following:
SELECT users.ID, users.Name, Message.ID, Message.TopicID, Message.UserID, Message.MessageText, Message.isReply
FROM Message
LEFT JOIN users ON Message.UserID = users.ID
WHERE Message.TopicID = '1' AND Message.isReply = '0'
This query gives me both messages in topic "1", but i do not know how to add in the "Count" to show the "isReply"
The query right now gives me:
users.ID users.Name Message.ID Message.TopicID Message.UserID Message.MessageText Message.isReply
1 Bob 1 1 1 Hello 0
3 Paul 5 1 3 Im New 0
What i would like is an extra column on the end that shows this:
ReplyCount:
3
2
So i can have the following:
Looking at TopicID = 1:
Message: Hello User: Bob Replies: 3
Message: Im New User: Paul Replies: 2
Looking at TopicID = 2:
Message: New Area User: Jack Replies: 1
Thanks again djjjozsi and Piranha 🙂
If anyone could help me add the "count" into my query, that would be amazing!
Regards,