选择具有1个值的列名称
我有一个这样的Oracle表:
MyTable
MENU ROLE1 ROLE2 ROLE3
MENU1 1 0 1
MENU2 0 1 0
MENU3 1 1 1
我需要一个查询,可以为我提供具有特定菜单行的值1的列名。
选择column_name 来自mytable 菜单='菜单1'
查询应产生cool1,proam3
I have an Oracle table set up like this:
MyTable
MENU ROLE1 ROLE2 ROLE3
MENU1 1 0 1
MENU2 0 1 0
MENU3 1 1 1
I need a query that will give me the columns names with value 1 for a specific menu row.
select column_name
from myTable
where menu = 'MENU1'
The query should produce ROLE1,ROLE3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如何通过
mytable
中的所有列循环的函数(菜单
),检查其值,以及 - 如果返回1
进入集合。样本数据:
测试:
How about a function that loops through all columns in
MYTABLE
(exceptMENU
), checks their values and - if1
is returned - adds that column into a collection.Sample data:
Testing:
您可以为3个角色创建3个视图。
1行影响
db<>>
You can create 3 views for the 3 roles.
1 rows affected
db<>fiddle here