用户登录
用户注册

分享至

T-SQL 中是否有三元条件运算符?

  • 作者: 花式撸管华北区总冠军
  • 来源: 51数据库
  • 2022-10-20

问题描述

实现以下查询的替代方法有哪些:

What are alternatives to implement the following query:

select *  
from table  
where isExternal = @type = 2 ? 1 : 0

推荐答案

使用case:

select *
from table
where isExternal = case @type when 2 then 1 else 0 end
软件
前端设计
程序设计
Java相关