• 数据表


    USE xu;
    CREATE TABLE ma(
    id INT PRIMARY KEY AUTO_INCREMENT,
    sname VARCHAR(500),
    age INT,
    sex VARCHAR(500),
    gongzi DOUBLE
    );
    INSERT INTO ma VALUES( 1,'一一',19,'男',1100 );
    INSERT INTO ma VALUES( 2,'二二',19,'女',1200);
    INSERT INTO ma VALUES( 3,'三三',21,'男',1300);
    INSERT INTO ma VALUES( 4,'四四',18,'女',1400 );
    INSERT INTO ma VALUES( 5,'五五',15,'男',1500 );
    INSERT INTO ma VALUES( 6,'六六',19,'女',1600 );
    INSERT INTO ma VALUES( 7,'七七',22,'男',1700 );
    INSERT INTO ma VALUES( 8,'八八',16,'女',1800 );
    INSERT INTO ma VALUES( 9,'九九',17,'男',1900 );
    INSERT INTO ma VALUES(10,'十十',20,'女',2000 );

    INSERT INTO ma VALUES( 11,'五五',15,'男',1500 );
    INSERT INTO ma VALUES( 12,'六六',19,'女',1600 );
    INSERT INTO ma VALUES( 13,'七七七',22,'男',1700 );

    SELECT id FROM ma;
    SELECT sname FROM ma;

    SELECT DISTINCT sname FROM ma;/*去掉 sname 重复的那一行*/
    SELECT gongzi AS gz FROM ma; /*别名 关键字as*/
    SELECT sname,gongzi+1000 FROM ma;/*对列进行运算*/

    SELECT *FROM ma WHERE gongzi>=1500;/*筛选出大于等于1500*/
    /*取值在1200到1800之间 between 。。。and*/
    SELECT *FROM ma WHERE gongzi BETWEEN 1200 AND 1800;

    /*模糊查询*/
    SELECT *FROM ma WHERE sname LIKE '四四';
    SELECT * FROM ma WHERE sex LIKE'男';
    SELECT * FROM ma WHERE sname LIKE'___';/*下划线有几个查找几个字的哪一行*/
    /*排序查询*/
    SELECT * FROM ma ORDER BY gongzi ASC;/*asc 升序*/
    SELECT * FROM ma ORDER BY gongzi DESC;/*desc 降序*/

  • 相关阅读:
    数组去重
    css盒模型
    px、em、rem的区别
    Html5新标签
    弹性布局
    相对定位与绝对定位
    Hadoop综合大作业
    分布式文件系统HDFS 练习
    安装Hadoop
    爬虫综合大作业
  • 原文地址:https://www.cnblogs.com/xuaima/p/10623525.html
Copyright © 2020-2023  润新知