title: dynamic MySQL query/view for crosstab
body: <p>I currently have a hard coded view with the following sql:</p>
  
  <pre><code>select username
      ,(case user_role.role_id when 1  then true else false end) as ROLE_SUPER 
      ,(case user_role.role_id when 2  then true else false end) as ROLE_ADMIN
      ,(case user_role.role_id when 3  then true else false end) as ROLE_VIEW
      ,(case user_role.role_id when 4  then true else false end) as ROLE_USER
      ,(case user_role.role_id when 5  then true else false end) as ROLE_EMAIL
      from user 
      left outer join user_role on user.id=user_role.user_id
      left outer join role on user_role.role_id = role.id;
  </code></pre>
  
  <p>my question is whether or not it is possible to dynamically generate role columns from the records in the role table.</p>