nodeJs learning -18 mysql database to understand

Intelligent video 24/25 Club

 

Four action statement:

  1,删  DELETE

    DELETE FROM table WHERE condition

  2, increasing  INSERT  

    INSERT INTO table (field list) VALUES (value list)

  3、改  UPDATE

    SET UPDATE Table = Value field, field = value, the WHERE condition ...

  4, check  SELECT

    SELECT * FROM table WHERE condition

 

  

Clause:

  WHERE condition

    WHERE name='blue'

    WHERE age>19

    WHERE age<=19

    WHERE AGE>=19 AND score<60

    WHERE cach>100 OR score>10000

 

  Sort ORDER

    ORDER BY age ASC/DESC

      ASC ascending order (small to large)

      DESC DESC (descending)

    ORDER BY price DESC

      Price descending order

    ORDER BY price ASC,scale DESC

      Price ascending order, if the price is the same, then sales in descending order

  

  Clustering GROUP - Consolidated same

    Counting COUNT, MIN, MAX, AVG, SUM

    SELECT class,COUNT(class)  FROM student_table GROUP BY class;

      Statistics class size

    SELECT class,AVG(score) FROM student_table GROUP BY class;

      Statistics for each class average

class    score
1    54.25
2    98.5
3    56.5

    

    SELECT class,MAX(score),MIN(score)  FROM student_table GROUP BY class;

      Statistics for each class highest score, lowest score

Score class name ID
 . 1. 1 Xiaoming 34 is 
2 2 red 98 
. 3. 1 Xiaogang 26 is 
. 4 2 Xiaohua 99 
. 5 for 3 strong 18 is 
. 6 four 3 hours 95 
. 7. 1 Liu 57 is 
. 8 florets. 1 100

    

    SELECT name,SUM(price) FROM sales_table GROUP BY name ORDER BY SUM(price) DESC;

      Query the total consumption of each person, and in descending order

name SUM (price) 
John Doe     119,000 
Zhang     74000 
Zhao six     18 is 
Blue     12 is

 

  LIMIT- limit output, pagination

    LIMIT 10; the first 10

    LIMIT 5,8; 5 from the beginning to 8

    limit (n-1) * 20,20 page n, page 20

 

Between the clauses are ordered:

  WHERE GROUP ORDER LIMIT filtered merge sorting limit

  例:SELECT class,COUNT(class) FROM student_table WHERE score>>60 GROUP BY class ORDER BY COUNT(class) DESC LIMIT2;

      

Database import and export:

  TABLE - Right - dump sql file - Select Address

  New Database - Right - run sql file

  

      

 

Guess you like

Origin www.cnblogs.com/LChenglong/p/11934655.html