CREATE PROCEDURE userCountries() BEGIN SELECT id, country FROM users, cities WHERE users.city = cities.city UNION SELECT DISTINCT id, "unknown" AS country FROM users, cities WHERE users.city NOT IN (SELECT city FROM cities) ORDER BY id; END