Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. select
  2. concat(`m`.`title`,"_",`a`.`title`) as `module_action`,
  3. if(isnull(`sp`.`flag`),0,1 ) as `is_sertificate`,
  4. if(isnull(`sp`.`flag`), `gp`.`flag`, `sp`.`flag`) as `flag`
  5.  
  6. from `users` `u`
  7. left join `groups` `g`
  8. on `g`.`id` = `u`.`group_id`
  9. left join `group_permissions` `gp`
  10. on `gp`.`group_id` = `g`.`id`
  11. left join `actions` `a`
  12. on `a`.`id` = `gp`.`action_id`
  13. left join `modules` `m`
  14. on `m`.`id` = `a`.`module_id`
  15.  
  16.  
  17. left join `user_sertificates` `us`
  18. on `us`.`user_id` = `u`.`id`
  19. left join `sertificates` `s`
  20. on `s`.`id` = `us`.`sertificate_id`
  21. left join `sertificate_permissions` `sp`
  22. on `sp`.`sertificate_id` = `us`.`sertificate_id`
  23. and `sp`.`action_id` = `a`.`id`
  24. where `u`.`id` = 1
  25. -- group by `a`.`id`
  26. order by `a`.`id` asc, `s`.`power` desc, `us`.`createdOn` desc, `sp`.`flag` desc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement