In one of my previous question, I have asked solution for resolving
mysql 1235 error:
Error Code: 1235. This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
Following will throw 1235 :
DELETE
FROM job_detail_history
where id not in (select id from job_detail_history order by start_time desc limit 2);
For that i got the solution which is given by @Zaynul Abadin Tuhin
as follows and it works for me too. He just added one single select layer over my subquery. and as per him it is suggested by some mysql experts.
Resolution For above problem:
DELETE
FROM job_detail_history
where id not in (select * from
(select id from job_detail_history order by start_time desc limit 2) as t1 );
I try to do analysis of DB table and i found that when i use
Problem :: this will not work with delete as explained above.
select id from job_detail_history order by start_time desc limit 2;
it return me something like this :
last null
was for new row as workbench suggest:
And when i add one extra layer of select :
adding extra layer of subquery : And this will work with my delete.
(select id from (select id from job_detail_history order by start_time desc limit 2) as t1);
it returns something like this :
So, what i want to understand
How subquery with one extra layer of resolve 1235 error?
can anyone eleborate it in detail.