去掉数据重复
增加两个字段
alter table t_employee add fsubcompany varchar(20);
alter table t_employee add fdepartment varchar(20);
给新加的字段赋值
update t_employee set fsubcompany=’beijing’,fdepartment=’development’ where fnumber=’dev001′;
update t_employee set fsubcompany=’shenzhen’,fdepartment=’development’ where fnumber=’dev002′;
update t_employee set fsubcompany=’beijing’,fdepartment=’humanresource’ where fnumber=’hr001′;
update t_employee set fsubcompany=’beijing’,fdepartment=’humanresource’ where fnumber=’hr002′;
update t_employee set fsubcompany=’beijing’,fdepartment=’infotech’ where fnumber=’it001′;
update t_employee set fsubcompany=’shenzhen’,fdepartment=’infotech’ where fnumber=’it002′;
update t_employee set fsubcompany=’beijing’,fdepartment=’sales’ where fnumber=’sales001′;
update t_employee set fsubcompany=’beijing’,fdepartment=’sales’ where fnumber=’sales002′;
update t_employee set fsubcompany=’shenzhen’,fdepartment=’sales’ where fnumber=’sales003′;
查询并去重
select distinct fdepartment from t_employee
select distinct fdepartment,fsubcompany from t_employee