Hey there, I'm new to mySQL, so my poor knowledge of the languages might be precluding me from searching for the result I need.
I am building a simple application in CodeIgniter that will access the Twitter API and return a table of status updates for a certain number of various users. I would like to limit this to showing 5 updates per user.
Imagine I have the following database, which is essentially a reduced version of my actual db.
person picture update
john pic 1 lorem ipsum
john pic 1 lorem ipsum
john pic 1 lorem ipsum
john pic 1 lorem ipsum
john pic 1 lorem ipsum
jim pic 2 lorem ipsum
jim pic 2 lorem ipsum
jim pic 2 lorem ipsum
jim pic 2 lorem ipsum
jim pic 2 lorem ipsum
joe pic 3 lorem ipsum
joe pic 3 lorem ipsum
joe pic 3 lorem ipsum
joe pic 3 lorem ipsum
joe pic 3 lorem ipsum
steve pic 4 lorem ipsum
steve pic 4 lorem ipsum
steve pic 4 lorem ipsum
steve pic 4 lorem ipsum
What I would like to do is to limit the number of updates per person on its way into the database using an SQL query.
I'm using INSERT IGNORE for my query, as each time the page is refreshed, I don't want duplicate entries inserted, but simply adding a LIMIT 5 limits 5 for the entirety of users. I would simply like to LIMIT 5 per user.
Is there any simple way to do this? REPLACE INTO? UPDATE? Sub-queries?
Thanks so much for any help you could give.