• mysql 语句


    数据库:
    SQL
    四大操作语句-
    1.删 DELETE
    DELETE FROM 表 WHERE 条件

    2.增 INSERT
    INSERT INTO 表 (字段列表) VALUES(值列表)

    3.改 UPDATE
    UPDATE 表 SET 字段=值,字段=值,... WHERE 条件

    4.查 SELECT
    SELECT * FROM 表 WHERE 条件

    ------------------------------------------------------------------------------

    子句:
    WHERE 条件

    WHERE name='blue'
    WHERE age>18
    WHERE age<=18
    WHERE age>=18 AND score<60
    WHERE cach>100 OR score>10000

    ORDER 排序
    ORDER BY age ASC/DESC
    ASC-升序(从小到大)
    DESC-降序(从大到小)

    --------------------------

    ORDER BY price ASC

    *价格(price)升序排序,如果价格相同,再按销量(sales)降序排序
    ORDER BY price ASC, sales DESC

    --------------------------

    GROUP 聚类-合并相同

    *统计每个班人数
    ID class name
    "1" "1" "小明"
    "2" "2" "小红"
    "3" "1" "小刚"
    "4" "2" "小华"
    "5" "3" "小强"
    "6" "3" "小四"
    "7" "1" "小刘"
    "8" "1" "小花"

    SELECT * FROM student_table;
    ID class name
    "1" "1" "小明"
    "2" "2" "小红"
    "3" "1" "小刚"
    "4" "2" "小华"
    "5" "3" "小强"
    "6" "3" "小四"
    "7" "1" "小刘"
    "8" "1" "小花"

    SELECT * FROM student_table GROUP BY class;
    ID class name
    "1" "1" "小明"
    "2" "2" "小红"
    "5" "3" "小强"

    SELECT class FROM student_table GROUP BY class;
    class
    "1"
    "2"
    "3"

    SELECT class,COUNT(class) FROM student_table GROUP BY class;
    class COUNT(class)
    1 4
    2 2
    3 2

    --------------------------

    WHERE子句
    ORDER子句——多条件排序
    GROUP子句——合并
    COUNT、MIN、MAX、AVG

    --------------------------

    GROUP

  • 相关阅读:
    oracle 导入数据语句
    移动上去换样式代码
    google suggest 代码例子
    删除一个表的字段的sql语句命令
    将json从前台传到后台注意问题
    eclipse 自动 getter setter 注释
    jsp界面获取地址栏参数
    常见的正则表达式验证
    JSTL 核心标签库
    javascript中的call和apply两个方法的区别
  • 原文地址:https://www.cnblogs.com/dekui/p/8617472.html
Copyright © 2020-2023  润新知