Let us say I have a table called animals
that looks like this:
1 red fox
2 blue elephant
3 red dog
4 yellow cat
5 green mouse
6 blue rat
In effect what I would like to do is make a temporary table (a virtual table) that only contains rows of the value I specify. For example red
:
1 red fox
3 red dog
and then grab a random row from this virtual table.
What I don't want to do is to permanently create these tables and have to constantly update them grabbing information from the main animals
table. I would like to do this on the fly and quickly using some sort of subquery, view, temporary table or whatever you would like to call it.
Please keep in mind that I am a complete php noob and could use as much clarification as possible involving syntax.