SELECT t1.`id`, COALESCE(t2.`index`, t1.`index`) as 'index'
FROM table_1 t1
LEFT JOIN table_2 t2 ON(t1.`id` = t2.`id`);
require_once('idna_convert.class.php');
$IDN = new idna_convert();
$domain = 'xn--j1ail.xn--p1ai';
$domain = $IDN->decode($domain);
echo $domain;