Q:

mysql statment that can select the first non null or first integer value

My user will select an initial year, I want mysql to select the value from coloumn for the initial year(let say 1990), But if there is no value for that initial year (1990) it should select the very first available value (let say for the year 1996)
I should try to select first non null value in this case but in my database instead of null I have a "-" for all unavailable values.
I guess I was mad to try a do-while loop which goes infinite....
do{
$sql="SELECT `$cityb` FROM data WHERE year=$initialyear";
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
if ($result) {
  while ($row = mysql_fetch_assoc($result)) {
      $valuei=$row["$cityb"];
      }

}         

$initailyear++;
}
while($value == "-"); //till when intial value is "-" (i.e no value)

This loop should end when a non "-" value is found. But it never ends.
So there must be a better alternative instead of using this stupid loop.

A:

SELECT stuff FROM data 
WHERE CONVERT(year, UNSIGNED INTEGER) >= 1990 
  AND year != '-' 
ORDER BY year 
LIMIT 1;

(Untested)

