mysqli error: [1093: ...] I have an SQL select, that gives two rows back.
The SQL update gives the error message 1093 back;


  mysqli error: [1093: Table 'HD_TICKET' is specified twice, both as a
  target for 'UPDATE' and as a separate source for data]


update HD_TICKET, HD_STATUS as T5
    set HD_TICKET.HD_STATUS_ID = T5.ID, 
HD_TICKET.TIME_OPENED  = IF(T5.STATE = 'opened', NOW(), HD_TICKET.TIME_OPENED), 
HD_TICKET.TIME_CLOSED  = IF(T5.STATE = 'closed', NOW(), HD_TICKET.TIME_CLOSED), 
HD_TICKET.TIME_STALLED = IF(T5.STATE = 'stalled', NOW(), HD_TICKET.TIME_STALLED), 
HD_TICKET.SATISFACTION_RATING = IF(T5.STATE = 'closed', NULL, HD_TICKET.SATISFACTION_RATING), 
HD_TICKET.SATISFACTION_COMMENT = IF(T5.STATE = 'closed', NULL, HD_TICKET.SATISFACTION_COMMENT), 
HD_TICKET.TITLE = (SELECT NAME FROM ORG1.ASSET WHERE ORG1.ASSET.ID = (SELECT ASSET_ID FROM HD_TICKET WHERE HD_TICKET.ID = HD_TICKET.PARENT_ID))
  where T5.NAME = 'New' and 
HD_TICKET.HD_QUEUE_ID = T5.HD_QUEUE_ID and
    (HD_TICKET.ID in (&lt;TICKET_IDS&gt;))


Can anybody help me, please? Thanks!
As far as I understand from the comments, you wanted a correlated subquery, to find the "parent" ticket and from that the realted asset (and its name):

HD_TICKET.TITLE = (SELECT NAME 
                   FROM ORG1.ASSET 
                   WHERE ORG1.ASSET.ID = (SELECT parent.ASSET_ID 
                                          FROM HD_TICKET AS parent
                                          WHERE parent.ID = HD_TICKET.PARENT_ID))


Now, you'd still get a similar error with the above code change, for the same reasons. MySQL does not allow the table that is updated to appear in a subquery in the WHERE clause.

Solution is to move the second reference to the table to the UPDATE clause and trasnform the subqueries into outer joins:

  left join HD_TICKET as PARENT 
    on PARENT.ID = T.PARENT_ID 
  left join ORG1.ASSET as A
    on A.ID = PARENT.ASSET_ID 


Since we did that, it feels right to convert the existing join to T5 to the same JOIN syntax as well:

update HD_TICKET as T
  join HD_STATUS as T5
    on T.HD_QUEUE_ID = T5.HD_QUEUE_ID
  left join HD_TICKET as PARENT 
    on PARENT.ID = T.PARENT_ID 
  left join ORG1.ASSET as A
    on A.ID = PARENT.ASSET_ID 
set 
  T.HD_STATUS_ID = T5.ID, 
  T.TIME_OPENED  = IF(T5.STATE = 'opened', NOW(), T.TIME_OPENED), 
  T.TIME_CLOSED  = IF(T5.STATE = 'closed', NOW(), T.TIME_CLOSED), 
  T.TIME_STALLED = IF(T5.STATE = 'stalled', NOW(), T.TIME_STALLED), 
  T.SATISFACTION_RATING = IF(T5.STATE = 'closed', NULL, T.SATISFACTION_RATING), 
  T.SATISFACTION_COMMENT = IF(T5.STATE = 'closed', NULL, T.SATISFACTION_COMMENT), 
  T.TITLE = A.NAME 
where T5.NAME = 'New'  
  and T.ID in (&lt;TICKET_IDS&gt;) ;