MySQL Forums
Forum List  »  Newbie

Noob question - simplist way to store last 4 viewed products?
Posted by: Marc M
Date: November 18, 2009 03:11AM

Ok this has got to be simpler than I'm making it out to be.

What is the simplest way to store only the last four viewed products by a user?

INSERT INTO last_viewed SET mem_id = '$mem_id', date = now(), product_id = '$id';

SELECT product_id FROM last_viewed WHERE mem_id = '$mem_id' ORDER BY date DESC LIMIT 4;

Ok that inserts and retrieves the records. But how do I remove the excess records beyond the four I need? Can I do that on the insert? Or do I need another query to do that? What would that be?

------------------------
Inner space - what a trip.

Options: ReplyQuote


Subject
Written By
Posted
Noob question - simplist way to store last 4 viewed products?
November 18, 2009 03:11AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.