title: MySQL VIEW table
body: <p>I am struggling how to create VIEW in MySQL.
  I have 5 tables:</p>
  
  <pre>
  - users - table with users data
  - groups - table with groups data
  - group_membership - relational table storing users memberships in groups
  - pages - table storing all pages data
  - permissions - relational table between pages and groups storing permissions to view page by group.
  </pre>
  
  <p>A VIEW that I want to create should show me which pages is user permitted to see according to his memberships in groups.
  Example:</p>
  
  <pre>
  User ID 1, is in groups 1, 2, 3
  group 1 has permission for pages 1,2,3
  group 2 has permission for pages 1,2,3,4
  group 3 has permission for pages 1,2,3,4,5,6,7
  </pre>
  
  <p>How I can create VIEW that will contain data like</p>
  
  <pre>
  user_ID  |  page_ID
  --------------------
  1        | 1
  1        | 2
  1        | 3
  1        | 4
  1        | 5
  1        | 6
  1        | 7
  </pre>
  
  <p>Thanks to everyone who can help.</p>