FROM (SELECT *,
IF(@ORID = ORID, @rownum := @rownum + 1, @rownum := 1) AS RowNum,
IF(@ORID <> ORID, @ORID := ORID, -999) s
FROM (SELECT *
WHERE ORID IN (SELECT ORID
GROUP BY ORID
HAVING COUNT(*) > 2000)) t1,
(SELECT @rownum := 1,
@ORID := -999) r
ORDER BY ORID,
ID DESC) t2
WHERE RowNum > 2000
ORDER BY ORID,
Open in new window
Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.
Lets say the FEED has fields ID (PK) and ORID,
2500 records with ORID=1
1500 records with ORID=2 << ignored
3700 records with ORID=3
I need to have the list of records
First 500 records with ORID=1 UNION First 1700 records with ORID=3
select ORID, count(ORID) as feed_count from feed
group by ORID
Select f1.id from feed as f1 where 2000 <
(Select feed_count from name_of_your_view as f2 where f2.ORID = f1.ORID)
order by ID desc
Select * from feed f1 where ID in (select id from name_of_second_view f2 where f1.ORID = f2.ORID LIMIT 2000,18446744073709551615)
order by ORID asc
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.