Modify a select query to delete a query

The following select query works fine:

SELECT * FROM JBPM_JOB job WHERE job.ACTION_ IN (SELECT ID_ from JBPM_ACTION WHERE ACTIONEXPRESSION_ LIKE '%#{reminderAction.addAsyncProcessReminder%warning%');

However, when I try to delete the lines found here, it fails

DELETE FROM JBPM_JOB job WHERE job.ACTION_ IN (SELECT ID_ from JBPM_ACTION WHERE ACTIONEXPRESSION_ LIKE '%#{reminderAction.addAsyncProcessReminder%warning%');

What is wrong here?

Error message:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'job WHERE job.ACTION_ IN (SELECT ID_ from JBPM_ACTION WHERE ACTIONEXPRESSION_ LI' at line 1

+3
source share
2 answers

You need to indicate what you are removing from the alias table, so use:

DELETE job FROM JBPM_JOB job WHERE job.ACTION_ IN (SELECT ID_ from JBPM_ACTION WHERE ACTIONEXPRESSION_ LIKE '%#{reminderAction.addAsyncProcessReminder%warning%');
+1
source

I tested the query on sql server. works fine, but it is possible that the values ​​you delete have some relationship with another table, for example PK and FK.

if they are, you also need to delete entries from these tables ..........

0
source

Source: https://habr.com/ru/post/1791442/


All Articles