SELECT *, temp_town.townUrl AS url, CONCAT(temp_town.pro, temp_town.mun) AS mun, province.proUrl AS pro, community.commUrl AS com FROM (temp_town) LEFT JOIN province ON temp_town.pro = province.proId LEFT JOIN community ON province.commId = community.commId WHERE `province`.`proUrl` = 'almeria' AND (temp_town.name = 'aguadulce' OR temp_town.townUrl = 'aguadulce')