MySQL DQL language data query language

1. Basic query
select field, field. . . from table name
as, distinct. . .
2. Conditional query
select. . . from table name where[query condition]
Comparison operator:>,<,>=,<=,=,!=,<>
Logical operator: and or not,
&&, ||, !
Sort: order by
aggregate function: max(), min(), count(), sum(), avg()...
Grouping: group by field
having. . .
Paging: limit start, cont
3. Multi-table joint query
A: Combine result set
UNION, UNION ALL
B: Multi-table joint query
a) Cartesian product
b) Inner join The
connection conditions, the retrieved data, all meet the connection conditions.
Dialect: select field. . . from table 1 alias 1, table 2 alias 2 where alias 1. field = alias 2. field
Standard : select field. . . from table 1 alias 1 inner join table 2 alias 2 on alias 1. field = alias 2. field
Natural : select field. . . from table 1 alias 1 natural inner join table 2 alias 2 
c) outer join to
supplement the result of inner join:
Left Outer Join:
Criteria: select field. . . from table 1 alias 1 left outer join table 2 alias 2 on alias 1. field = alias 2. field
Natural : select field. . . from table 1 alias 1 natural left outer join table 2 alias 2
right outer join
Standard : select field. . . from table 1 alias 1 right outer join table 2 alias 2 on alias 1. field = alias 2. field
Natural : select field. . . from table 1 alias 1 natural right outer join table 2 alias 2
full outer:
left outer UNION right outer
d) Self-connection
A table connects itself to itself. .
4. In the subquery
select statement, you can include the select statement
where, use the result of the subquery as the filter condition
from, and use the result of the subquery as the temporary table
Syntax requirements: 1. must (), 2. cannot use order by, 3. It cannot exceed 255 at most.
A: Single-line
sub- query The result of the sub-query, the returned result is one, with: =,!=,<>,>,<,>=,<=
B: Multi-line
sub- query The result of the sub-query, the returned result is the result It is multiple (as a set), with: in, any, all
C: Correlated subquery The
outer query uses the result of the inner query, and the inner query uses the content of the outer query.


Guess you like

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