Need to delete data from table_a. We have to delete data from table_a. So table_a join with table_b(It is done using subquery).
delete from table_a where id in (SELECT GROUP_CONCAT(N.id) FROM table_a N
INNER JOIN table_b E ON N.form_id=E.form_id and N.element_id=E.element_id
WHERE N.option_value=0 AND E.element_type IN('checkbox','radio','select')
AND N.id BETWEEN 13000 AND 14001);
When i exeute the above query, getting error is given below
You can't specify target table 'table_a' for update in FROM clause
How to fix this issue.
I have tried with the below query. is it ok?
delete from table_a where id in (SELECT * FROM(SELECT GROUP_CONCAT(N.id) FROM table_a N
INNER JOIN table_b E ON N.form_id=E.form_id and N.element_id=E.element_id
WHERE N.option_value=0 AND E.element_type IN('checkbox','radio','select')
AND N.id BETWEEN 13000 AND 14001)tblTmp);