테이블에서 반환 된 행이없는 경우 더미 값을 가져와야합니다. If는 자체적으로 작동하지만 연합에 오류가 발생합니다. 누군가 나를 해결책이나 해결 방법으로 안내해 줄 수 있습니까?Union과 If Exists - 함께 작동하지 않음 - 도와주세요
create table test1 (col1 varchar(10))
create table test2 (col1 varchar(10))
create table test3 (col1 varchar(10))
insert test1 values ('test1-row1')
insert test1 values ('test1-row2')
insert test2 values ('test2-row1')
insert test2 values ('test2-row2')
select col1 from test1
union
select col1 from test2
union
if exists (select * from test3)
select col1 from test3
else
select 'dummy'
으로 변경하십시오. 고맙습니다. – user267277