SELECT a.per_ID as AddToCart, CONCAT('<a href=PersonView.php?PersonID=',a.per_ID,'>',a.per_FirstName,' ',a.per_LastName,'</a>') AS Name FROM person_per AS a LEFT JOIN person_custom pc ON a.per_id = pc.per_ID WHERE pc.~custom~='~value~' ORDER BY per_LastName