I am dealing with phone system and have to work with multiple service vendors. For one vendor I have a MySQL table country_codes like this –
---------------------------------------------------------
country_code | area_code | country
---------------------------------------------------------
93 | 93 | Afghanistan
0 | 9375 | Afghanistan Cellular-AT
0 | 9370 | Afghanistan Cellular-AWCC
355 | 355 | Albania
0 | 35568 | Albania Cellular-AMC
0 | 35567 | Albania Cellular-Eagle
213 | 213 | Algeria
0 | 21377 | Algeria Cellular-Djezzy
0 | 2135 | Algeria Cellular-Wataniya
---------------------------------------------------------
and so on…
The country_code column wasn’t there before but I added it since I needed it for my PHP application. I managed to update the country codes for some records (using answer from my previous question here)
What I want to achieve is to replace the 0’s with the respective country code. So the table should look like this –
---------------------------------------------------------
country_code | area_code | country
---------------------------------------------------------
93 | 93 | Afghanistan
93 | 9375 | Afghanistan Cellular-AT
93 | 9370 | Afghanistan Cellular-AWCC
355 | 355 | Albania
355 | 35568 | Albania Cellular-AMC
355 | 35567 | Albania Cellular-Eagle
213 | 213 | Algeria
213 | 21377 | Algeria Cellular-Djezzy
213 | 2135 | Algeria Cellular-Wataniya
---------------------------------------------------------
I hope I explained myself well enough. Any idea how can I do that with PHP-MySQL ?
(I don’t mind using PHP code to manipulate the table this way)
Try this query –