1.去除重复两种方式
1.1distinct 函数
select distinct userid from projectinfo where projecttype in (select id from p_fundcategory where departid = 21 and parentid !=0)
1.2 group by 也可以
select userid,count(userid) from projectinfo where projecttype in (select id from p_fundcategory where departid = 21 and parentid !=0) group by userid
函数ltrim左边空格
函数rtrim右边空格
两个函数联合使用ltrim(rtrim(name)) 就可以了