I need an idea how to construct this query.
I have a web page. each time the page is refreshed, I want to select data from a random category, and to select no more than 4 random items from that category.
For example, with different types of music as my categories, and songs from that type of music as my items, three separate refreshes might return:
categoryid name title 212 rap making it 212 rap falling hard 212 rap kill it 212 rap gone wide
categoryid name title 200 blues under you 200 blues loving 200 blues moving 200 blues mine world
categoryid name title 312 rock lazy 312 rock nice 312 rock stoned 312 rock my world
I believe I'm supposed to use a sub-query to return this.
So, the category should be selected at random, the songs within that category should be selected at random (unless there are 4 or fewer songs, in which case they'll all be shown), and the order of the songs should be random.
How would I go about doing this?