SQL--chapter02 Query Basics

Source: Internet
Author: User
Tags logical operators

SELECT Statement Basics

SELECT < column name >,.....

From < table name >;

Query all columns: SELECT * from < table name >;

Use the AS keyword to set the alias for the column, and set the Chinese alias to enclose it in double quotation marks (").

Use distinct in a SELECT statement to delete duplicate rows.

Where: To follow the FROM clause, first use the WHERE clause to query for a record that matches the specified criteria, and then select the column specified by the SELECT statement.

A comment is a section of an SQL statement that identifies a description or note, divided into 1 lines of comments (written after "-") and multiline comments (written between "/*" and "/*", which can span multiple lines).

Arithmetic operations conform to comparison operators

A SELECT clause can use a constant or an expression.

Be sure to note the position of the inequality and equal signs when using comparison operators. (You can use! = and <> in MySQL)

Data of type string is sorted in dictionary order in principle. Cannot be confused with the size order of the numbers.

When you want to select a null record, you need to use the IS null operator in the conditional expression. When you want to select records that are NOT NULL, you need to use the is not NULL operator in the conditional expression.

logical operators

The NOT operator is used to negate a condition, but it cannot be abused.

When multiple query conditions are combined, you need to use the AND operator or the OR operator.

The AND operator has a higher precedence than the OR operator. Parentheses are used when you want to prioritize or operations.

SQL--chapter02 Query Basics

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.