views:

24

answers:

1

I'm MySQL, I have a table full of docs. Each row represents a doc. I'd like to have a data column for "VIEWS" that automatically adds +1 every time the row is accessed and avoid needing to write a SQL UPDATE that hits the DB after the SELECT to get the doc in the web app.

Any smart clever ways to solve for this?

Thanks

+1  A: 

You can't add triggers to select statements, so besides writing a stored procedure to fetch the row and increment the view count at the same time there is no really clean way to do it.

WoLpH