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

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

Jun 07, 2016 pm 06:02 PM
Assignment

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
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to enable copy and paste for VMware virtual machines How to enable copy and paste for VMware virtual machines Feb 21, 2024 am 10:09 AM

You can easily copy and paste text and files between VMware virtual machines (VMs) and physical systems. This capability allows you to easily transfer images, formatted and unformatted text, and even email attachments between virtual machines and host systems. This article will show you how to enable this feature and demonstrate methods for copying data, files, and folders. How to Enable Copy/Paste in VMware VMware provides three different ways to copy data, files or folders from a virtual machine to a physical computer and vice versa, as explained below: Copy and Paste Elements Drag and Drop Feature Folder Sharing 1 ] Enable copy-paste using VMware Tools You can use the keyboard if your VMWare installation and guest operating system meet the requirements

How to copy a page in Word How to copy a page in Word Feb 20, 2024 am 10:09 AM

Want to copy a page in Microsoft Word and keep the formatting intact? This is a smart idea because duplicating pages in Word can be a useful time-saving technique when you want to create multiple copies of a specific document layout or format. This guide will walk you through the step-by-step process of copying pages in Word, whether you are creating a template or copying a specific page in a document. These simple instructions are designed to help you easily recreate your page without having to start from scratch. Why copy pages in Microsoft Word? There are several reasons why copying pages in Word is very beneficial: When you have a document with a specific layout or format that you want to copy. Unlike recreating the entire page from scratch

Disable or enable automatic copy selection for copying in Terminal Disable or enable automatic copy selection for copying in Terminal Mar 24, 2024 am 09:46 AM

This article will show you how to enable or disable automatic copying of selections to the clipboard in Windows Terminal. Windows Terminal is a multi-tab terminal emulator developed by Microsoft specifically for Windows 11/10, replacing the traditional command prompt. It supports running applications such as Command Prompt, PowerShell, WSL, Azure, etc. Often when working in the terminal, users need to copy commands and output, however the terminal does not support copying selection operations by default. Keep reading this article to learn how to fix this issue. How to enable or disable automatic copying of selections to cache in Terminal? Here's how you can enable or disable automatic copying of selections to the Terminal clipboard: Open the Terminal application and click above

Unlock macOS clipboard history, efficient copy and paste techniques Unlock macOS clipboard history, efficient copy and paste techniques Feb 19, 2024 pm 01:18 PM

On Mac, it's common to need to copy and paste content between different documents. The macOS clipboard only retains the last copied item, which limits our work efficiency. Fortunately, there are some third-party applications that can help us view and manage our clipboard history easily. How to View Clipboard Contents in Finder There is a built-in clipboard viewer in Finder, allowing you to view the contents of the current clipboard at any time to avoid pasting errors. The operation is very simple: open the Finder, click the Edit menu, and then select Show Clipboard. Although the function of viewing the contents of the clipboard in the Finder is small, there are a few points to note: the clipboard viewer in the Finder can only display the contents and cannot edit them. If you copied

What are the assignment methods in php? What are the assignment methods in php? Jul 26, 2023 pm 01:11 PM

The assignment methods in PHP include: 1. Direct assignment, use the "=" operator to directly assign a value to a variable; 2. Reference assignment, use the "=&" operator to assign a reference to a variable to another variable; 3. Dynamic assignment , using variable variables to assign values ​​through the string form of variable names; 4. Array assignment, assigning an array to another variable; 5. List assignment, assigning the value of an array to a set of variables, and multiple assignments can be made at one time value; 6. Object assignment, assign an object to a variable; 7. Use the extended form of the assignment operator, such as +=, -=, etc.

Tips and Notes: Different String Array Assignment Methods Tips and Notes: Different String Array Assignment Methods Dec 26, 2023 am 11:30 AM

Introduction to tips and precautions for using different ways to assign values ​​to string arrays: In programming, it is often necessary to use arrays to store a set of related data. Especially when dealing with strings, it is often necessary to use string arrays to store multiple strings. This article will introduce some common methods, tips and precautions for assigning values ​​to string arrays, and provide code examples. Direct assignment Direct assignment is the simplest way. You can directly assign values ​​to the array elements while declaring the string array. The sample code is as follows: String[]fruit

What are the methods of assigning values ​​to string arrays? What are the methods of assigning values ​​to string arrays? Dec 25, 2023 pm 05:07 PM

The assignment methods of string arrays in common programming languages: 1. Python: "string_array = ["apple", "banana", "cherry"]"; 2. Java: "String[] stringArray = {"apple", "banana" ", "cherry"}"; 3. C++ and so on.

Learn variable definition and assignment in Golang Learn variable definition and assignment in Golang Jan 18, 2024 am 10:00 AM

The definition and assignment of variables in Golang require specific code examples. In Golang, the definition and assignment of variables are very simple and intuitive. This article will introduce the definition and assignment of variables in Golang through specific code examples. First, let's take a look at the definition of variables in Golang. In Golang, the definition of variables can be done using the var keyword. The specific syntax is as follows: var variable name type. Among them, var represents the definition keyword of the variable, and the variable name is the variable you define.

See all articles