clear markdown feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3364508 fiddles created (36240 in the last week).

CREATE TABLE roles_modulos ( modulo_id INT, role_id INT ); INSERT INTO roles_modulos (modulo_id, role_id) VALUES (1,2),(2,1),(2,2),(2,4),(2,5),(3,4),(4,5); CREATE TABLE modulos ( id INT, nombre VARCHAR(100) ); INSERT INTO modulos (id, nombre) VALUES (1,'Admin'),(2,'Reportes'),(3,'Usuarios'),(4,'Roles'); CREATE TABLE roles ( id INT, nombre VARCHAR(100) ); SELECT IIF(RM.modulo_id IS NULL, 'False', 'True') AS 'Estado', M.nombre AS 'Modulo', M.id AS 'modulo_id', R.nombre AS 'Rol', RM.role_id FROM modulos AS M LEFT JOIN roles_modulos AS RM ON RM.modulo_id = M.id AND RM.role_id = 5 LEFT JOIN roles AS R ON RM.role_id = R.id;
Estado Modulo modulo_id Rol role_id
False Admin 1
True Reportes 2 5
False Usuarios 3
True Roles 4 5
 hidden batch(es)