2012-04-17 8 views

답변

9

테이블 이름 등을 설명하는 열 목록에 상수를 추가하십시오 (예 :

select *, 'TableA' as TableName 
from TableA 
union all 
select *, 'TableB' as TableName 
from TableB 
order by TableName 
+0

감사 남자 (당신의 열 col1col2 있다고 가정) 별도의 열을 생성 할 수 있습니다. 정확히 내가 무엇을 찾고 있었는지. –

0

당신은

select col1,col2,table_1 as table_name 
from table_1 
union 
select col1,col2,table_2 as table_name 
from table_2 
order by col1,table_name; 
관련 문제