You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') UNION (SELECT v2 as v, d, nom ' at line 4
(SELECT v1 as v, d, nom FROM `v_distance_25` JOIN villes ON v1=villes.insee WHERE `v2` = ) UNION (SELECT v2 as v, d, nom FROM `v_distance_25` JOIN villes ON v2=villes.insee WHERE `v1` = ) ORDER BY d, nom