Frog Frog recommended: Organize some SQL database skills, paste

Source: Internet
Author: User
Frog Frog recommended: Organize some SQL database skills, paste
How to delete a column in a table that repeats, for example
Table [table1]
ID Name
1 AA
2 BB
3 cc
1 AA
2 BB
3 cc
I think the last watch is like this.
ID Name
1 AA
2 BB
3 cc
Reply:
Save the record in a temporary table #t, save a duplicate record, and then save the record in the temporary table #t back into the original table, noting that "SELECT DISTINCT Id,class,name" contains all the fields you need, otherwise some fields are deleted.
Execute the following code in the query manager:
-----------------------------
SELECT DISTINCT ID,, name
Into #t
From table1 DELETE table1
INSERT
into table1
SELECT *
From #t
------------------------------
Two. Find people who will both VB and PHP
The table is like this:
ID Employee Skills
1 1 VB
2 1 PHP
3 1 ASP
4 2 PHP
5 3 ASP
6 4 VB
7 4 ASP
From this table to find both VB and PHP, how to write SQL?
Reply:
---------------------------------------------------------------------------------------------
Select employee from [table] where employee in (select employee from [table] where skill = ' VB ') and skill = ' PHP '
----------------------------------------------------------------------------------------------
Three. Database Consolidation issues
Two tables in Access that want to merge the contents of two tables
The table [a] structure is as follows:
[ID] Number autonumber
[Name] Name text
[Prices] Price number
[Guige] Specification text
[Changjia] Manufacturer's text
[Baozhuang] Wrapping text
[Danwei] Unit text
A total of 900 records, except the ID and Name fields, all other can be empty
The table [b] structure is as follows:
[ID] Number autonumber
[Name] Name text
[Prices] Price number
[Changjia] Manufacturer's text
[Danwei] Unit text
[Xingzhi] nature of the text
A total of 800 records, in addition to the ID and name fields, less than table [a] a few fields, but also more than one [Xingzhi] of the word Fuan other can be empty
Now you want to generate a new table [C], which is structured as follows, and content is the sum of the contents of two tables,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.