Using MySQL, write a query to retrieve a list of all customer ids, names, and phone numbers with their country codes concatenated with their phone numbers. Sort the output in the order of their customer_id.
There are two tables in the database:
1) customers
Contains customer_id, name, phone_number, and country.
2) country_codes
Contains the country code for every country.
Example:
customers
customer_id name phone_number country
1 Raghav 951341341 India
2 Jake 52341351 USA
3 Alice 61341351 USA
country_codes
country country_code
USA 1
India 91
Sample Output
1 Raghav +91951341341
2 Jake +152341351
3 Alice +161341351
Explanation:
• Since Raghav is from India, the country code is 91, so the complete phone number is +91951341341
• Since Jake is from the USA, the country code is 1, and the complete phone number is +152341351
• Since Alice is from the USA, the country code is 1, and the complete phone number is +161341351
Note: The phone number should be in the following format: +COUNTRY_CODE PHONENUMBER (without spaces)