SQL - MySQL Advanced Query 2

Disclaimer: The materials used in this column are written by VIP students of Kaige Academy. Students have the right to remain anonymous and have the right to final interpretation of the article. Kaige Academy aims to promote VIP students to learn from each other based on public notes.

mysql advanced query 2

Select advanced query has the following syntaxes, fuzzy query like, sub query, record set union.

Fuzzy query like has the following three symbols %, _, []. The syntax is as follows:

% represents any number, any character. E.g:

SELECT * FROM shaicheng WHERE username LIKE '%里%';

SELECT * FROM shaicheng WHERE username LIKE '%里';

_ represents any single character. The syntax is as follows:

SELECT * FROM SHAICHENG WHERE GROUPNAME LIKE '_士';

SELECT * FROM SHAICHENG WHERE changci LIKE '__场';

[AB] One character is optional.

The subquery syntax is as follows:

image

If there are two joined tables,

image

If you are a relational operator, the result of the subquery can only be one (single row and single column). If you want to do multi-line value judgment, there is in. The in syntax is as follows:

image

The record set union syntax is as follows:

image

image

The queried column names are displayed according to the column names of the first table. The empty query syntax is as follows:

image

Sorts and conditions can be written on the last query statement:

image

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326411184&siteId=291194637