create table [premiumuser] (user_id int, name nvarchar(50));
create table [liteuser] (user_id int, name nvarchar(50));
create table [feature] (id nvarchar(50), user_id int, userkey int);
insert into [premiumuser] select 1, 'stephen';
insert into [premiumuser] select 2, 'roger';
insert into [liteuser] select 1, 'apollo';
insert into [liteuser] select 2, 'venus';
insert into feature select 'Upload content', 1, 1;
insert into feature select 'Create account', 1, 0;
insert into feature select 'View content', 2, 0;
我想查看功能表中的数据,而不是userid
我想要的username
.
这里的问题是如果userkey
为 0,username
则从liteuser表中获取,否则从高级用户表中获取。
数据应该像
'Upload content', 'stephen', 1
'Create account', 'apollo', 0
'View content', 'venus', 0