• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    SQL学习笔记五去重,给新加字段赋值的方法
    去掉数据重复
    增加两个字段
    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
    您可能感兴趣的文章:
    • 在CRUD操作中与业务无关的SQL字段赋值的方法
    上一篇:SQL学习笔记四 聚合函数、排序方法
    下一篇:SQL学习笔记六 union联合结果集使用
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯 版权所有

    《增值电信业务经营许可证》 苏ICP备15040257号-8

    SQL学习笔记五去重,给新加字段赋值的方法 SQL,学习,笔记,五去重,给,