For anyone pulling his hair out because of the poor performance of ON CONCAT() joins: make sure you cast your non string values to CHAR it improves the performance astronomically:
SELECT t1.name t1_name,
t2.name t2_name
FROM table1 t1 LEFT JOIN
table2 t2 ON CONCAT(t1.country, '.', CAST(t1.id AS CHAR) ) = t2.code
Explanation hides in MySQL docs for CONCAT() function:
…If all arguments are non-binary strings, the result is a non-binary
string. If the arguments include any binary strings, the result is a
binary string. A numeric argument is converted to its equivalent
binary string form; if you want to avoid that, you can use an explicit
type cast…
Credit for this goes to Aurimas Mikalauskas.
FROM tabel1rather thantable2?