MySQL Common query statement summary (not updated regularly ....) )

Source: Internet
Author: User

In this article I will introduce some examples of common SQL statement directories in everyday programming:
    • # 1. Establishment of the database

    • # # 2. Common queries

# 1. An example of a database is given in the form of an ER diagram:

4 relational patterns from this conversion: Note: The underscore is a straight line key, and the underscore is a red dashed line for the foreign key

This allows you to create the following database: C: S: SC: T:

For a specific database setup script, check out my github

# # 2. Common queries
    • Query for the minimum age of four persons (sorted by age from small to large, if same age, in name order)
SELECT * from S  ORDER by age Asc,convert (SName USING GBK) LIMIT 4

    • Check the first two courses of exam time (Examdate is datetime type data)
SELECT * from CORDER by Examdate Asc,convert (cName USING GBK) LIMIT 2

    • Get three student data at a random
SELECT * from SORDER by RAND () LIMIT 3

MySQL Common query statement summary (not updated regularly ....) )

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.