I'm trying to make a support ticket system, I would like to know
How would you display how many replies an issue hasthe date of the last replyThanks
What is your DB architecture like?
I would have 2 tables:
(1) Tickets which contains all ticket information such as title, issue, member who submitted the ticket, createDate, and TicketID.
(2) TicketReplies which contains all replies for a ticket, a createDate, and a foreign key TicketID.
You can set createDate default binding = getDate() which will return the current dateTime.
If you need to know how many replies there are for a ticket you can run:
SELECT COUNT(*)
FROM TicketReplies tr
JOIN Tickets t
ON tr.TicketID = t.TicketID
WHERE t.TicketID = (whatever the ticket is that you are interested in)
If you need to know the date of the last reply you can run:
SELECT *
FROM TicketReplies tr
JOIN Tickets t
ON tr.TicketID = t.TicketID
WHERE t.TicketID = (whatever the ticket is that you are interested in)
ORDER BY CreateDate DESC
0 comments:
Post a Comment