MySQL Update

I have the following update query.

db_query(“UPDATE $sql_tbl[products] SET avail='”.intval (($temp_avail[0][“avail”] - $amount)).“’ WHERE productid = ‘$productid’”);

I want the query to also include:

If $temp_avail[0][“avail”] - $amount = 0

db_query(“UPDATE $sql_tbl[products] SET avail=‘1’ WHERE productid = ‘$productid’”);

If $temp_avail[0][“avail”] - $amount = 1 or above

Then run this:

db_query(“UPDATE $sql_tbl[products] SET avail='”.intval (($temp_avail[0][“avail”] - $amount)).“’ WHERE productid = ‘$productid’”);

Any ideas?