limiting consecutive values of one column in a sql query.

Posted by Brad Smith on Stack Overflow See other posts from Stack Overflow or by Brad Smith
Published on 2010-04-23T00:59:07Z Indexed on 2010/04/23 1:03 UTC
Read the original article Hit count: 310

Filed under:
|
|

I have a table with the following structure:

id           -int(11)
event_id     -int(11)
photo_id     -int(11)
created_at   -datetime

How do I write a query that will return the 100 most recent rows, but insuring that there are no more than 4 consecutive rows with the same value in photo_id

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sql