zoukankan      html  css  js  c++  java
  • Python学习第二十三课——Mysql 表记录的一些基本操作 (查)

    查(select * from 表名)

    基本语法:

      select <字段1,字段2,...> from <表名> where <表达式>;

      例如,查询student表中所有的记录,在终端窗口输入命令:

     

      select id,name,age from employee;

     

    也可以查询限定的记录,输入如下命令,可以限定查询结果为第0条到第1条记录,也就是返回第一条记录:

    select * from empolyee limit 0,3;

     

    也可以查询通过年龄限制查询

    select * from employee where age between 18 and 20;

     模糊查询(like):

    select * from employee where name like "阿%";

    查询空值:

    select name from employee where salary is null;

    排序查询(order by)

    select name,chengji from employee order by chengji;

    select name,chengji from employee where chengji>50 order by chengji;

     降序查询:

    select name,chengji from employee where chengji>50 order by chengji desc;

    as 可以添加一个字段:

    select name,chengji1+chengji2 as 总成绩 from employee;
    select name,chengji1+chengji2 as 总成绩 from employee order by 总成绩;
     

     

    分组查询 group by :

    注意:按分组条件分组每一组只会显示第一条记录;


    select * from employee group by name;(按照name分组 name一样的将被分为一组)

  • 相关阅读:
    鲁迅散文——随感录三十五
    跳一跳201803-1
    鲁迅散文——狗的驳诘
    鲁迅散文——立论
    小中大201903-1
    鲁迅散文——题辞
    小明上学201812-1
    买菜201809-2
    Linux常用命令-2
    LaTeX——基本介绍及字体设置
  • 原文地址:https://www.cnblogs.com/pyhan/p/12332135.html
Copyright © 2011-2022 走看看