I have a table that looks like this:
--------------------------------
| name | email | friend |
--------------------------------
1 | bob | bobs email | kate |
--------------------------------
2 | bob | bobs email | joe |
--------------------------------
3 | tim | tims email | eddie |
How can I create new columns (friend1
, friend2
, etc.) and move friends there, on the condition that name and email are the same (there might be two bobs, for instance, bob and bob with a different email).
My desired table looks like this:
-----------------------------------------------------
| name | email | friend1 | friend2 | friend3 |
-----------------------------------------------------
1 | bob | bobs email | kate | joe | |
-----------------------------------------------------
2 | tim | tims email | eddie | | |