如果我很了解您的表的结构,那么这将选择当前用户的权限,然后选择其相关信息,以防它不为空,否则选择列,这意味着该列没有条件
declare @country nvarchar(50), @region nvarchar(50), @brand nvarchar(50)
set @country=(Select [t2].[permission]
from [t2] where [t2].[type]='country'
and [t2].[user_id] = {{current_userId()}})
set @brand=(Select [t2].[permission]
from [t2] where [t2].[type]='brand'
and [t2].[user_id] = {{current_userId()}})
set @region=(Select [t2].[permission]
from [t2] where [t2].[type]='region'
and [t2].[user_id] = {{current_userId()}})
select * from [t1] where
[t1].[country]= case when @country IS NULL
then [t1].[country] else @country end
and [t1].[brand]= case when @brand IS NULL
then [t1].[brand] else @brand end
and [t1].[region]= case when @region IS NULL
then [t1].[region] else @region end