Last night, a friend mentioned to me that one day he was trying to fetch a random 5 rows from a MySQL database. He researched online, and was eventually presented with a working solution in which he would generate five random numbers. Then, he would query the database for items whose ID number matched the numbers. If an item didn't exist (because it had been deleted, etc.) then he would randomly generate a different number and fetch again. He would continuously do this in a loop until he had five unique rows fetched from the database. I was caught off …

Member Avatar
Member Avatar
+4 forum 5

# MySQL Stored Routines: Another Useful Scenario # [In a past guide](http://blog.bobbyhensley.com/sql-procedures-functions-authentication-example/) I discussed MySQL stored routines within MySQL. Now I’m back with another guide on MySQL stored routines. And this time it’s a more concrete case; one that you may run into yourself in the future (or maybe you already have)! Let’s jump right on, shall we? ## The scenario… ## You’re implementing a comments system to your application. Users will be able to comment on articles you and your staff post. A concern arises: **explicit comments**. It’s something all web developers have to deal with: people being crude …

Member Avatar
Member Avatar
+2 forum 1

The End.