silent_coder
silent_coder

Reputation: 6512

mysql get count of items after offset

Let's assume I have 100 records in my table.

I need to build query which return me how much queries I have after making some offset. Something like select count(*) from Table offset 30 and this query in described case should return 70

How I could do this in mysql?

Upvotes: 1

Views: 1786

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269923

Do you just want a subquery?

select count(*)
from (select t.*
      from table t
      offset 30
     ) t;

Or simple arithmetic:

select greatest(count(*) - 30, 0)
from table t;

Upvotes: 7

Related Questions