CONCAT()

$sql = ” SELECT  CONCAT(country_code,\’–> \’,country_name)\n”
. “FROM apps_countries”;

Description

MySQL CONCAT function is used to concatenate two strings to form a single string. In this example it can concat the country code and country name and give the result in single string.

Output

The output of the above example will be like this:
AF–> Afghanistan
AL–> Albania
DZ–> Algeria
DS–> American Samoa
AD–> Andorra
AO–> Angola
AI–> Anguilla
AQ–> Antarctica
AG–> Antigua and Barbuda
AR–> Argentina
AM–> Armenia
AW–> Aruba
AU–> Australia
AT–> Austria
AZ–> Azerbaijan
BS–> Bahamas
BH–> Bahrain
BD–> Bangladesh
BB–> Barbados
BY–> Belarus
BE–> Belgium
BZ–> Belize
BJ–> Benin
BM–> Bermuda

Advertisements