tags:

views:

48

answers:

2

I am having trouble counting the number of rows until it reaches a certain PK.

My PK is called id and I want to count all rows until i reach a specified id

I have tried using this query but it doesn't work probably becuase I am using a MySQL table

select max(count(*)) from news where id=18 group by id

I get this error

Invalid use of group function

+3  A: 

Try this:

select count(*) from news where id <= 18
Michael Buen
So simple......don't know why i didn't see that
AdRock
+3  A: 
select count(*) from news where id<=18 
Salil