[man]if[/man], [man]elseif[/man], and [man]else[/man] are control structures; in some languages these are called conditionals. If takes an boolean expression as its one (and only one) argument. If it evaluates true, then the conditional statements that follow are executed.
Now, likely that's not news to you? Your question is a tad tricky, because of the way it's phrased.
Let's assume MySQL? The point seems to be that if $first exists, you want to call that in the query?
if ($first) {
$query = "SELECT DISTINCT `male` FROM `alpha` WHERE 1 AND `male` LIKE '$first%'";
} else {
$query = "SELECT DISTINCT `male` FROM `alpha` WHERE 1 AND `male` LIKE 'a%'";
}
However, if the point is to change the query based on whether or not the first query returns a result (with MySQL), then the boolean value of [man]mysql_query/man can be tested:
$query = "SELECT DISTINCT `male` FROM `alpha` WHERE 1 AND `male` LIKE '$first%'";
$good_query=mysql_query($query);
if (!$good_query) {
$query = "SELECT DISTINCT `male` FROM `alpha` WHERE 1 AND `male` LIKE 'a%'";
}
Of course, that's performing one query already --- if your goal was to only query once, we've defeated it.
And then, the last possibility: I've not been able to figure out your question at all, or there are mitigating circumstances; either way, sorry I can't help in that case...
HTH,