I am trying to alter a table to add an additional column and populate the new column based on another column. For example I have a table that looks like this:
+----+------------+----------+
| id | username | role |
+----+------------+----------+
| 1 | foo | admin |
+----+------------+----------+
| 2 | bar | operator |
+----+------------+----------+
I want to add a column named tenant and based on the value in role column populate the value inside tenent:
+----+------------+----------+--------------+
| id | username | role | permissions |
+----+------------+----------+--------------+
| 1 | foo | admin | * |
+----+------------+----------+--------------+
| 2 | bar | operator | limited |
+----+------------+----------+--------------+
Is there a MySQL query that can be performed or will I need to create a script to do this?
CASEstatement? <softwaretestinghelp.com/mysql-case-statement/#MySQL_CASE_Syntax>