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;
I would like to see the data from the function table , but instead useridI want username.
The trap here, if userkeyequal to 0, get the table usernamefrom liteuser , otherwise from the table the premium user .
Data should be similar to
'Upload content', 'stephen', 1
'Create account', 'apollo', 0
'View content', 'venus', 0
source
share