SQL语句为:
select smi.menu_id,smi.menu_parent_id,smi.menu_name,
case
when smi.menu_id in (select menu_id from customer_menu_role where role_id=2)
then 'true'
else 'false'
END
as checked
from customer_menu_info smi;
上述语句进行了:
1\ 先查询了角色2拥有的menu_id;
2\ 再查询并判断了smi.menu_id是否是上面查询的值; 或者说在上面查询的集合中;
3\ 是则true, 否则为false, END as为新增的列起别名.
查询结果: