Is it possible to populate a field in function of data stored in another field? I explain me better: in a database there is a field “telnum” (telephone number) where are stored telepnone numbers with international prefix. Can i populate the “country” field in function of the prefix of each number using a php command?
This is the database:
______________________________________________
| id | telnum | name | country |
----------------------------------------------
| 01 | 003912377 | Smith | |
| 02 | 004412345 | White | |
| 03 | 005454321 | Lopez | |
The “php command” should associate to each different prefix the country name in my sql table. In the example we have 0039 -> Italy, 0044 -> UK, 0054 -> Argentina… and so on.
Result must be this:
______________________________________________
| id | telnum | name | country |
----------------------------------------------
| 01 | 003912377 | Smith | Italy |
| 02 | 004412345 | White | UK |
| 03 | 005454321 | Lopez | Argentina |
Thanks in advance to everybody for your help.
Greetings, Mattew
You can use
casestatement within a query