반응형
T-SQL에 3진수 조건 연산자가 있나요?
다음 쿼리를 구현하기 위한 대체 방법은 무엇입니까?
select *
from table
where isExternal = @type = 2 ? 1 : 0
SQL Server 2012에서는 다음 기능을 사용할 수 있습니다.
SELECT *
FROM table
WHERE isExternal = IIF(@type = 2, 1, 0)
주의: T-SQL에서 할당(및 비교) 연산자는=
(그리고 아니다)==
- C#입니다.)
사용하다case
:
select *
from table
where isExternal = case @type when 2 then 1 else 0 end
언급URL : https://stackoverflow.com/questions/16209751/is-there-a-ternary-conditional-operator-in-t-sql
반응형
'programing' 카테고리의 다른 글
WPF 차트 컨트롤 (0) | 2023.04.17 |
---|---|
Powershell에서 로그 파일 생성 (0) | 2023.04.17 |
리모트 저장소 HEAD와 동일하게 로컬 저장소 브랜치를 리셋합니다. (0) | 2023.04.12 |
VS 2017 : 보안 디버깅 옵션이 설정되었지만 사용할 수 없는 Visual Studio 호스팅 프로세스가 필요합니다. (0) | 2023.04.12 |
큰따옴표 또는 작은따옴표를 삽입하는 방법 (0) | 2023.04.12 |