select A.*,case when (select count(*) from tb_jc_xz B where A.parentid = B.uid) >0
then cast((select B.mc from tb_jc_xz B wh
ere A.parentid = B.uid) as VARCHAR)+'-'+A.mc else A.mc end as id from tb_jc_xz A
select A.*,case when (select count(*) from tb_jc_xz B where A.parentid = B.uid) >0
then cast((select B.mc from tb_jc_xz B wh
ere A.parentid = B.uid) as VARCHAR)+'-'+A.mc else A.mc end as id from tb_jc_xz A