Sql 是否可以使用IN子句返回select语句的结果?

Sql 是否可以使用IN子句返回select语句的结果?,sql,tsql,Sql,Tsql,我正在尝试这样做: select ('hi' in ('hi')) as hi 由于“in”部分的语法错误,它无法工作 是否可以使用IN子句返回子查询的布尔结果?您可以使用CASE使用条件表达式: select case when 'hi' in ('hi') then 1 else 0 end .尝试一个案例,例如 select case when 'hi' in ('hi') then 1 else 0 end as hi 我相信您可以使用case语句将条

我正在尝试这样做:

select ('hi' in ('hi')) as hi
由于“in”部分的语法错误,它无法工作


是否可以使用IN子句返回子查询的布尔结果?

您可以使用
CASE
使用条件表达式:

select
    case when 'hi' in ('hi') then 1 else 0 end
.

尝试一个案例,例如

select 
  case 
     when 'hi' in ('hi') then 1 else 0 
 end as hi

我相信您可以使用case语句将条件值作为一个位返回:

select case when 'hi' in ('hi') then 1 else 0 end as hi