MySQL Learning Path (v) MySQL advanced query

Source: Internet
Author: User
Tags joins

MySQL statistics function

Count (): Statistic quantity;

Max (): Statistical maximum;

Min (): Minimum statistical value;

AVG (): Statistical averages;

SUM (): statistics and;

Select Count (* from student;

MySQL sort group by;

The default is ascending sort;

Select *  fromStudentGroup  bySidASC;--Sort AscendingSelect *  fromStudentGroup  bySidDESC;--Sort DescendingSelect *  fromStudentGroup  bySid,sname;---Multi-field sorting

Having the same use method and where, the function is more powerful than where;

Limit limit Query

Limit queries a specified number of data in a data table

Limit can only limit the query

Mainly used to achieve paging effect;

Select *  from 1 ; -- Query 1 Data Select *  from 1,2; -- starting from subscript 1 to query two data;

MySQL connection query

Cross joins: Crosses join; loops out each record from a table, each record is connected to another table;

Connection mode: Left table cross join right table;

Inner joins: Left table inner join right table on condition;

Alias: As (can save As)

External links: outer join;

Outer LEFT join;

outer right join;

Select *  fromStudent Cross JoinStudent2;Select *  fromStudentInner JoinStudent2 onStudent.sid=Student2.sid;Select *  fromStudent asAInner JoinStudent2 b onA.sid=B.sid;Select *  fromStudent asA Left outer JoinStudent2 b onA.sid=B.sid;Select *  fromStudent asA Right outer JoinStudent2 b onA.sid=B.sid;

Multi-Table Query Union (ALL;DISTINCT)

All: Do not go to the weight, keep all the data;

Distinct: Remove weight (default);

MySQL Learning Path (v) MySQL advanced query

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.