Hmm, not too familiar with the MySQL If/Else syntaxes, but it seems that you are missing a THEN and END IF statement.
I guess (but not sure as I never used it before) it should be something like this:
IF(`products.parent_upn` != '0') THEN
SELECT `parent_upn` AS `upn`FROM `products` WHERE ...... ;
ELSE
SELECT `upn` AS `upn`FROM `products` WHERE ...... ;
END IF;
END
You can read more about it in the MySQL Manual.
You could also try this to achieve what you want.
$query = "SELECT `parent_upn`, `upn` FROM `products` WHERE ....";
$assoc = mysql_fetch_assoc($query);
if ($assoc['parent_upn']!="0"); {
$query2 = "SELECT `parent_upn` AS `upn` FROM `products` WHERE ....";
} else {
$query2 = "SELECT `upn` AS `upn` FROM `products` WHERE ....";
}
Bit more work, but should do the trick aswell.