I have started adding LIMIT 1 to the bottom of the update query as a fail safe when using ticket rules when I am expecting to only update 1 ticket. If you know why... you know why. :)
For visual here is a simple update query using the example from the little blue help icon above the update query when creating/editing a ticket rule.
The help icon states that the below QUERY 1 will be changed to QUERY2 when executed.
I add one line to the bottom of that seen underlined in QUERY 3 which will save you from accidentally updating every ticket on accident.
update HD_TICKET
set TITLE = 'changed'
where HD_TICKET.ID in (<TICKET_IDS>)
**** QUERY 2 ****
update HD_TICKET
set TITLE = 'changed'
where HD_TICKET.ID in (1,2,3)
**** QUERY 3 ****
update HD_TICKET
set TITLE = 'changed'
where HD_TICKET.ID in (<TICKET_IDS>)
LIMIT 1
Here is a screenshot of this in action with before and after results from MySQL Workbench and the results from Last Run Log for confirmation. I also highlighted with a red arrow that the select query did indeed return 4 id's.
Ideally you would want to pass ONLY the ID's to the update query that you want to perform an update on. Again this is just a safety measure I use for myself that others might be find useful.
Comments