select *,'合同' as type_name from table where type=1 union select *,'卖身契' as type_name from table where type=2 union select *,'契约' as type_name from table where type=3 ...... 取type_name
select *, case when type=1 then "合同" as type_name when type=2 then "房契" as type_name else "" as type_name end from table
union
select *,'卖身契' as type_name from table where type=2
union
select *,'契约' as type_name from table where type=3
......
取type_name