I have 2 tables, Resource and views and I'm trying to get the list of all the items from Resource table whose ran_resId don't match with the ran_resId of last 2 records of views table. I'm trying to use LIMIT in my sub-query which is giving this error:
This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'`
Here's my query -
select r.res_id, r.res_name
from Resource AS r
where r.ran_resId NOT IN
( select v.ran_resId
from views AS v
order by v.viewsid
limit 2
)
group by r.ran_resId
I've google it and found out that LIMIT can't be use in SubQuery in MySql, And as an alternate I could use JOIN however I'm not able to create the query to get the desired results.
A help is highly appreciated.
PS - I'm using MySql 5.6
