SELECT
r.role_id as id,
pid as "pId",
name AS "name",
(
CASE WHEN (
pid = 0
OR pid IS NULL
) THEN 'true' ELSE 'false' END
) as "open",
(
CASE WHEN (
r1.role_id = 0
OR r1.role_id IS NULL
) THEN 'false' ELSE 'true' END
) as "checked"
FROM
sys_role r
LEFT JOIN (
SELECT
role_id
FROM
sys_role
WHERE
role_id IN ( #{params} )
) r1 ON r.role_id = r1.role_id
ORDER BY
pid,
sort ASC;
等价于
SELECT
r.role_id as id,
pid as "pId",
name AS "name",
(
CASE WHEN (
pid = 0
OR pid IS NULL
) THEN 'true' ELSE 'false' END
) AS "open",
(
CASE WHEN ( r.role_id = 0 OR
r.role_id IN ( #{params} )
) THEN 'false' ELSE 'true' END
) AS "checked"
FROM
sys_role r
ORDER BY
pid,
sort ASC;
描述
原查询
等价于
可能的修改方法
见#93