The most basic SELECT command _ MySQL

Source: Internet
Author: User
The most basic SELECT command or statement is used to obtain record information in one or more tables. it is generally used with the where clause to obtain
If no where clause exists, all records are returned. The general usage is as follows:

SELECT attribute-list
FROM table-name
WHERE condition

Attribute-list: list of returned content, separated by commas. The content here can be a field, containing the expression of the field
Or more complex subqueries.

Table-name: name of a table. if it is more complex, it can be a subquery.

Condition: A condition expression used to filter records that meet the condition.

In this section, we use the following table for testing:

Bbc (name, region, area, population, gdp)
The table name is bbc. The table has five columns, also known as attribute ).
Name: country name
Region: region of the country
Area: area
Population: population
Gdp: gdp

SQL instance:
1. select the names, regions, and population of all countries.
SELECT name, region, population FROM bbc


2. provide the population of France
SELECT population FROM bbc
WHERE name = 'France'

3. which country names start with the character D?
SELECT name FROM bbc
WHERE name LIKE 'd %'

IV. country names and population density of large land countries (with an area greater than 5 million square kilometers)
SELECT name, population/area FROM bbc
WHERE area> 5000000

V. countries with small (area less than 2000 square kilometers) and rich (GDP greater than 5 billion)
SELECT name, region
FROM bbc
WHERE area <2000
AND gdp> 5000000000

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.