I have a table with both Male & Female genders (PK (Id), PersonsName, IsMale). I wish to get a random name but for both genders. Example:
Select Top 1 PersonsName
From MyTable
Where IsMale = '1'
Order by NewID()
Select Top 1 PersonsName
From MyTable
Where IsMale = '0'
Order by NewID()
How can I combine those statements so I return 2 records (1 male and 1 female name) from the one SQL statement?
I have seen on here in the past that someone just separated the two statements in the same SQL query, like so:
Select Top 1 PersonsName
From MyTable
Where IsMale = '1'
Order by NewID();
Select Top 1 PersonsName
From MyTable
Where IsMale = '0'
Order by NewID()
Each time the code is run I wish to have two totally random names and not two records of the same gender so I can populate the dataset and bind it to a ListView control. I just need the SQL statement