I have two table Name as 'ApplicationRoles' and 'FormSchema'.
I have to select result based on passing Tenant column like -'A' or 'All' -'B' or 'All' -'C' or 'All' and so on.
Now i have to get result by joining both table based on below condition.And in query Tenant 'All' is default and it is common between other tenant.
Condition: let suppose in query if i am passing Tenant as 'A' then in result all rows belong to Tenant 'A' as well as Tenant 'All' but not Tenant 'All' one row which is already there in Tenant 'A'.
please see the fiddle for table and record. for example dbfiddle I am supplying Tenant as 'A'.then below row should not come in result because SchemaName Car already came in result through Tenant 'A'.
55b7f5e3-b8bd-4857-8db6-11d0eae92194 Car 40ecca83-7fd9-4d63-9f56-c7a48442d844 #Test-1 All
Tried query:
select * from (select fs1.schemaid,fs1.schemaName,ar1.roleId,ar1.roleName,ar1.tenant from
(select ar.SchemaId,ar.Tenant,ar.RoleId,ar.RoleName,ar.Capability
from ApplicationRoles ar) ar1
full outer join
(select fs.SchemaId,fs.SchemaName,fs.Tenant,fs.Capability from FormSchema fs) fs1
on ar1.SchemaId= fs1.SchemaId) as t3
where (t3.Tenant='All' or t3.tenant='A')
How to get Result if SchemaName is already there then not select 'All' Tenant row.