写的不太好,欢迎高手指点 select c.colno,c.colname,sc.idxname FROM syscolumns c join SYSCONSTRAINTS sc on sc.tabid = c.tabid join ( select idxname,part1 as colno from SYSINDEXES si where tabid=107 and part1 >0 union all select idxname,part2 as colno from SYSINDEXES si where tabid=107 and part2 >0 union all select idxname,part3 as colno from SYSINDEXES si where tabid=107 and part3 >0 union all select idxname,part4 as colno from SYSINDEXES si where tabid=107 and part4 >0 union all select idxname,part5 as colno from SYSINDEXES si where tabid=107 and part5 >0 union all select idxname,part6 as colno from SYSINDEXES si where tabid=107 and part6 >0 union all select idxname,part7 as colno from SYSINDEXES si where tabid=107 and part7 >0 union all select idxname,part8 as colno from SYSINDEXES si where tabid=107 and part8 >0 union all select idxname,part9 as colno from SYSINDEXES si where tabid=107 and part9 >0 union all select idxname,part10 as colno from SYSINDEXES si where tabid=107 and part10 >0 union all select idxname,part11 as colno from SYSINDEXES si where tabid=107 and part11 >0 union all select idxname,part12 as colno from SYSINDEXES si where tabid=107 and part12 >0 ) as t on t.colno = c.colno and t.idxname =sc.idxname where c.tabid=107 and sc.constrtype = 'P'