SQL base de-weight and display table structure (iv)

Source: Internet
Author: User

When we query through the SELECT statement, we find a lot of the same information, and this time we want to remove the duplicate information what to do?

For example, here are the repetitions, where we can use distinct to come and go heavy

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/8D/CC/wKiom1iq2j6jXXvbAAAihuik55E105.jpg-wh_500x0-wm_ 3-wmp_4-s_1526407360.jpg "title=" qq20170220182614.jpg "alt=" Wkiom1iq2j6jxxvbaaaihuik55e105.jpg-wh_50 "/>


Let's say there are people working in those departments of the query department. You can also query by using the following statement.

SELECT distinct department_id as dep_id from Employees order by DEP_ID;

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/8D/CC/wKiom1iq2sDTMoTbAAA30Tz1rx8943.jpg-wh_500x0-wm_ 3-wmp_4-s_2107587508.jpg "title=" qq20170220182614.jpg "alt=" Wkiom1iq2sdtmotbaaa30tz1rx8943.jpg-wh_50 "/>


Second, the Display table structure

Use the DESCRIBE command to display the table structure.

Desc[ribe] TableName

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/8D/C9/wKioL1iq3Vqwe1mTAAA21OSlzsI649.jpg-wh_500x0-wm_ 3-wmp_4-s_3015245109.jpg "title=" qq20170220182614.jpg "alt=" Wkiol1iq3vqwe1mtaaa21oslzsi649.jpg-wh_50 "/>

or use SQL Developer software to view

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M00/8D/C9/wKioL1iq3smQc2xXAADW_C_65FI724.jpg-wh_500x0-wm_ 3-wmp_4-s_3413793553.jpg "title=" qq20170220182614.jpg "alt=" Wkiol1iq3smqc2xxaadw_c_65fi724.jpg-wh_50 "/>


Three, for example, we now have regions and countries two tables, their table structure is as follows

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/8D/C9/wKioL1iq5gTzmfOSAAAsPrgBJUw931.jpg-wh_500x0-wm_ 3-wmp_4-s_2711613219.jpg "title=" qq20170220204300.jpg "alt=" Wkiol1iq5gtzmfosaaasprgbjuw931.jpg-wh_50 "/>


650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/8D/CC/wKiom1iq5d3D7yqjAAA1FsGpgQ0318.jpg-wh_500x0-wm_ 3-wmp_4-s_1206233589.jpg "title=" qq20170220204300.jpg "alt=" Wkiom1iq5d3d7yqjaaa1fsgpgq0318.jpg-wh_50 "/>


What if we want to find a country in Europe? What the hell?

1, first we find the Asian number in the region, through the following we know the label of Asia is 3

SELECT * from region;

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/8D/C9/wKioL1iq5tTz5qAcAAAt8cqCOFg499.jpg-wh_500x0-wm_ 3-wmp_4-s_2520929464.jpg "title=" qq20170220204300.jpg "alt=" Wkiol1iq5ttz5qacaaat8cqcofg499.jpg-wh_50 "/>

2, we in the countries table inside the tea axis region_id 3 Country name will be possible (found our motherland China ^_^)

Select Country_id,country_name from countries where region_id=3;

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/8D/C9/wKioL1iq53WBo49cAAA7g8Dsb-U306.jpg-wh_500x0-wm_ 3-wmp_4-s_324481909.jpg "title=" qq20170220204300.jpg "alt=" Wkiol1iq53wbo49caaa7g8dsb-u306.jpg-wh_50 "/>

This article is from the "record a bit of learning life" blog, please make sure to keep this source http://ureysky.blog.51cto.com/2893832/1899630

SQL base de-weight and display table structure (iv)

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.