美文网首页
Mysql基础语句

Mysql基础语句

作者: 沈神奇 | 来源:发表于2018-10-26 00:04 被阅读0次

    /*增*/ 

    INSERT INTO students (name,age) VALUES ("神奇美",18) /*插入数据*/

    /*删*/ 

    DELETE FROM students WHERE id = 5 AND NAME = "神奇美"  /*删除数据并没有删除id*/

    /*改*/ 

    UPDATE students SET sex = "女" WHERE id = 5 /*更新数据*/

    /*查*/ 

    SELECT * FROM students ORDER BY age DESC  /*查询学生表年两由大到小降序排列 反之ASC是升序*/

    SELECT * FROM students ORDER BY age ASC

    SELECT * FROM students GROUP BY sex /*根据性别分组*/

    SELECT name FROM students /*查询n所有name*/

    SELECT * FROM students WHERE sex = "男" /*查询表中条件性别为男的数据*/

    SELECT COUNT(1) from students /*统计表中有多少条数据*/

    SELECT COUNT(1) from students WHERE sex = "女" /*统计表中性别为女的条数数据*/

    /*创建表*/

    CREATE TABLE techer (

    id INT(11) NOT NULL PRIMARY KEY auto_increment, #id 整形 不能为空 主键 自动递增

    name VARCHAR(255)

    )

    相关文章

      网友评论

          本文标题:Mysql基础语句

          本文链接:https://www.haomeiwen.com/subject/lpmhtqtx.html