MySQL and Random Row Selection

I’ve been working on a quiz section for one of my websites lately, well tried to anyway. One of the dumbest things happened. In a quiz you want to randomly pick questions and serve them to the visitor. That way they can answer them and shout WAHOO once they have one right.

Problem I had was that I couldn’t figure out how to sort all the questions in a completely random order, well semi random any way (since a computer does not know random as we do). I tried to do this by first counting the number of rows in the table and then creating a random array with 0..x (x being the number of rows). But this is very inefficient.

[Read More]

SQL The Basics

Strange title isn’t. Is there such a thing as basic SQL(Structured Query Language). Lets try and find out. I will be covering some basics, thus creating a simple table. Making some basic queries and basics on T-SQL (Transact SQL).

Why use databases

Best to begin with a little story I suppose. Why would you want to use a database? Well it’s pretty easy. Databases give you the capability to store massive amounts of data in a orderly manner. With easy and structured access. I can hear those lovers of files shouting that you can do the same with files. I’ll grant them this, files can store information in the same way. But when it comes to quick access or easy manipulation then nothing beats databases.

[Read More]