1、select role_auth_ids from test_role where role_name='經(jīng)理' 的執(zhí)行結(jié)果:
+------------+
role_auth_ids
+------------+
1,2,3
2、select auth_name from test_auth where auth_id in (1,2,3)的執(zhí)行結(jié)果:
+------+
auth_name
+------+
商品管理
商品添加
商品編輯
但是,將1、2條語句合并后,即select auth_name from test_auth where auth_id in (select role_auth_ids from test_role where role_name='經(jīng)理'),執(zhí)行結(jié)果只有一條數(shù)據(jù),也就是只有商品管理一個(gè)數(shù)據(jù)。這是why?
SELECT auth_name FROM test_auth WHERE auth_id IN (SELECT replace(concat('''',role_auth_ids,''''),',',''',''') FROM test_role WHERE role_name = '經(jīng)理 ') 給in子句加上單引號(hào)也不行..................
請(qǐng)教各位大神我該如何才能從通過test_role中role_auth_ids查詢出對(duì)應(yīng)的test_auth表中的auth_name呢?
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com