MySQL Forums
Forum List  »  Newbie

Join Issues
Posted by: Mr Mr
Date: November 01, 2017 11:19AM

Hi all,

I've been working on writing a query to pull info from our helpdesk database.

Here is what I'm trying to do.


Table ObjectCustomFieldValues - ObjectID is common to Tickets.ID

id | CustomField | ObjectID | Content
--------------------------------------------
1 2 1 PD
2 3 1 Outlook
3 2 2 WD
4 3 2 Software
5 2 3 IT
6 3 3 Email


Table Tickets

id | Status | Starts | Started | Due | Resolved
1 Resolved 10-2 3:45 10-2 4:10 10-7 12:00 10-5 1:35
2 Resolved 10-4 8:00 10-4 8:02 10-9 12:00 10-4 9:32
3 Resolved 10-4 9:15 10-4 9:42 10-9 12:00 10-6 8:17


Current Results

id | Status | Starts | Started | Due | Resolved | Content
1 Resolved 10-2 3:45 10-2 4:10 10-7 12:00 10-5 1:35 PD
1 Resolved 10-2 3:45 10-2 4:10 10-7 12:00 10-5 1:35 Outlook
2 Resolved 10-4 8:00 10-4 8:02 10-9 12:00 10-4 9:32 WD
2 Resolved 10-4 8:00 10-4 8:02 10-9 12:00 10-4 9:32 Software
3 Resolved 10-4 9:15 10-4 9:42 10-9 12:00 10-6 8:17 IT
3 Resolved 10-4 9:15 10-4 9:42 10-9 12:00 10-6 8:17 Email


Expected Results

id | Status | Starts | Started | Due | Resolved | Department | Reason
1 Resolved 10-2 3:45 10-2 4:10 10-7 12:00 10-5 1:35 PD Outlook
2 Resolved 10-4 8:00 10-4 8:02 10-9 12:00 10-4 9:32 WD Software
3 Resolved 10-4 9:15 10-4 9:42 10-9 12:00 10-6 8:17 IT Email

Current query I'm running right now is:

use rt4;

select Tickets.id, Tickets.Status, Tickets.starts, Tickets.started, Tickets.due, Tickets.resolved, ObjectCustomFieldValues.Content

from Tickets

Left Join ObjectCustomFieldValues on Tickets.ID = ObjectCustomFieldValues.ObjectId
Order by Tickets.id, ObjectCustomFieldValues.CustomField;

I know this is something simple but I'm having a brain fart.
Thank you,
-Steve

Options: ReplyQuote


Subject
Written By
Posted
Join Issues
November 01, 2017 11:19AM
November 01, 2017 01:29PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.