I have several queues in our K1000 and I am new to SQL of any variety.  I am trying to have a ticket rule that will populate parent ticket fields into child ticket fields for a new process, but I want to limit this rule to only a single queue.  During my testing a have been able to select and update from parent to child mostly due to http://www.itninja.com/user/jverbosk many posts and blogs on the topic.  So many thanks to him for getting me this far.

My problem is that when I run the rule, which is located in the queue both the parent and child will live in, this runs in all queues.  Luckily I don't have many parent/child tickets out there so I only botched a few older tickets of little consequence.  Based on some posts from 2012 and 2013 I am using HD_TICKET.HD_QUEUE_ID = 3 to try to select only this one queue, but I get an error that states "Error Code: 1054. Unknown column 'HD_TICKET.HD_QUEUE_ID' in 'where clause' "  It doesn't matter which queue I try, and I have verified this queue number several times.  Same error in MySQL Workbench and my K1000.

Here is my code:

SELECT PARENT.HD_IMPACT_ID, CHILD.HD_IMPACT_ID
FROM HD_TICKET PARENT, HD_TICKET CHILD
WHERE ((HD_TICKET.HD_QUEUE_ID = 3) and PARENT.ID = CHILD.PARENT_ID)

Any help would be greatly appreciated.



Answer Summary:
Cancel
1 Comment   [ + ] Show Comment

Comments

  • Being a complete newb with this, I didn't realize I had an alias since there was no AS statement. But once I look at what chucksteel said it does make sense that it was aliased. My query now works on only the one queue.

    Clearly I need to continue learn this language and try to get a better grip.
Please log in to comment

Answer Chosen by the Author

1
You have aliased the HD_TICKET table as PARENT and CHILD so when referencing those tables you need to use the alias. In your where clause use PARENT.HD_QUEUE_ID=3. 

Answered 10/12/2015 by: chucksteel
Red Belt

Please log in to comment

Answers

This content is currently hidden from public view.
Reason: Removed by member request
For more information, visit our FAQ's.

0
you may need a join

like

JOIN HD_QUEUE Q ON Q.ID = HD_TICKET.HD_QUEUE_ID WHERE (HD_TICKET.HD_QUEUE_ID = 1)
Answered 10/08/2015 by: SMal.tmcc
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity