I have more than a hundred records in table A belonging to three categories. I need to choose randomly ten records from each category and pair them such that each pair has two records from different categories. I will save these 15 pairs (30 records) in another table B and will be retrieving data from table B by pair. I will be retrieving two records (one pair) at a time from table B and both these records should belong to different categories. What could be the best way to do this?