11.21 MySQL learning records and 11.21mysql records

Source: Internet
Author: User

11.21 MySQL learning records and 11.21mysql records

2017-11-21 17:51:04

Select *
From world. city;

Select countrycode
From world. city;

/* The distinct keyword applies to all columns, not just the column following */
Select distinct countrycode
From world. city;


/* Retrieve the first five rows of Data */
Select district
From world. city
Limit 5;


/* Search for five rows of data starting from row 10 */
Select district
From world. city
Limit 10, 5;

/* In alphabetical order */
Select Name
From world. city
Order by name;

/* Sort by GNP first and then by Continent (order by 2 and 3 can achieve the same effect, but it is prone to errors when changing )*/
Select name, GNP, Continent
From world. country
Order by GNP, Continent;

/* To perform descending order on multiple columns, add desc after the target column */
Select name, region, population
From world. country
Order by population desc;

/* The order by statement must be placed after the where statement */
Select name, region, population
From world. country
Where population> = 1000000
Order by population;

Select name, region, population
From world. country
Where population between 5000000 and 10000000;

/* The and keyword links two conditions or the keyword meets one of the conditions to return data */
Select name, district, population
From world. city
Where CountryCode = 'phl' and Population> = 400000

/* Brackets should be used to use the where clause with the or and operator at any time )*/
Select name, district, population
From world. city
Where (CountryCode = 'phl' or CountryCode = 'bra ')
And Population >=400000

 

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.