I work for a hosting company were we often get requests for installs, new domains, lag fixes etc. To get a bit of an overview of what is still open I decided to make a really simple ticket system. I have a bit of php knowledge and a bit of MySQL knowledge. For now we will be submitting the tickets ourselves based on e-mails and phonecalls from customers.
I have created the following SQL structure:
|| TICKETS || || STATUSSES || || STATUS-CODES ||
-------------- ---------------- -------------------
| ID | | ticket_id | | ID |
| cust_name | | status_id | | status_txt |
| cust_cntct | | datetime | -------------------
| subject | ----------------
| message |
--------------
I now want to make the overviw table showing all the existing tickets. A ticket is inserted with a default status. The concurring timestamp will be the time that the ticket was added. Every time a ticket moves to the next status a new status will be added with a timestamp. The newest status is always the current status.
I can’t figure out how to create a query that will get every ticket with its latest status. A simple join will return a ticket as many times as the amount of statusses it has. I want to create a join but only show the results were the timestamp of the status is the newest for a certain ticket.
Try this: