wildcard expansion using sql I've a table named permissions. 

CREATE TABLE `permissions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `role_code` varchar(45) NOT NULL,
  `permission` varchar(100) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


It has data such as

+----+--------------+----------------------+
| id |  role_code   |      permission      |
+----+--------------+----------------------+
|  1 | ADMIN        | app.*                |
|  2 | LOC_ADMIN    | app.location.*       |
|  3 | LOC_READER   | app.location.read    |
|  4 | LOC_APPROVER | app.location.approve |
|  2 | EMP_ADMIN    | app.employee.*       |
|  3 | EMP_READER   | app.employee.read    |
|  4 | EMP_APPROVER | app.employee.approve |
+----+--------------+----------------------+


I would like to query this table to get list of fine-grained permissions for a given role_code

For e.g., for role_code 'ADMIN' I would like to get 

app.location.read
app.location.approve
app.employee.read
app.employee.approve


Is it possible to write a SQL query to achieve this?  

Thanks for your help.
Your specification does raise some questions, but should be easily possible.

Since % is a wildcard character, and * is not, then you might want to use % as your marker. 

+----+--------------+----------------------+
| id |  role_code   |      permission      |
+----+--------------+----------------------+
|  1 | ADMIN        | app.%                |
|  2 | LOC_ADMIN    | app.location.%       |
|  3 | LOC_READER   | app.location.read    |
|  4 | LOC_APPROVER | app.location.approve |
|  2 | EMP_ADMIN    | app.employee.%       |
|  3 | EMP_READER   | app.employee.read    |
|  4 | EMP_APPROVER | app.employee.approve |
+----+--------------+----------------------+


If so, then you could run code something like this:

SELECT a.role_code, b.permission
FROM permissionstable a
  JOIN permissionstable b on a.permission LIKE b.permission
       and RIGHT(b.permission,1) &lt;&gt; '%'
  ORDER BY b.permission


This does depend on my understanding of the permission strings.