MySQL operation details and good habits -------- updating..., -------- updating

Source: Internet
Author: User

MySQL operation details and good habits -------- updating..., -------- updating

1. Try not to write too complex SQL queries, and do not think about returning all the results in the form required by the previous end at a time. You can separate the queries multiple times so that the logic is clear, fast problem solving, easy maintenance, and high SQL efficiency.

2. When you use a join Table query, the length of the joined table must not be too long. Otherwise, the query efficiency will be greatly affected. The actual situation at work is that when the length of the joined table is close to 1000, the speed will decrease significantly.

3. About group:

  • After grouping BY, the result is aggregated into a "GROUP". It is mostly used to remove duplicates or return statistics from different groups, such as the maximum value or something. That is, only one value in the same GROUP of data is returned, it can be used with group_contact to connect multiple data of the same field and return it as a field. If you need to return all the data in different groups, you cannot use group by (group by didn't do well at the beginning ...)
  • Group by x means to put all records with the same X field value in a GROUP.
  • Group by x, Y means to put all records with the same X field value and Y field value into a GROUP.

 

 

Related Article

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.