score:1

Accepted answer
select * from table as t1
where (select count(*) from table as t2
       where t1.user_id = t2.user_id and t2.id < t1.id) <3

Read More

score:0

If you want only 3 rows, you can use limit :

select * from myTable limit 3;

score:0

score:1

SELECT *
FROM table
ORDER BY ...
LIMIT 3

The LIMIT clause takes two arguments: number of rows to return, and an offset if you want to display something other than the first X rows. Details here in the MySQL docs.


More questions with similar tag