Regional Indicator Symbols in Unicode are the codes starting at U+1F1E6 to U+1F1FF. If you combine two of them in a valid ISO-3166-1 alpha-2 codes, they produce the flag corresponding to that code. We want a function flag_emoji() that takes such a two-letter code and emits the appropriate Unicode codepoint: SELECT flag_emoji('GB') AS gb, flag_emoji('us') AS us, flag_emoji('de') AS de \G gb: π¬π§ us: πΊπΈ de: π©πͺ 1 row in set (0.00 sec) MySQL For that, we define a helper function ...