• mysql查询表内容


    一,说明:表名为student

    1,查询某个表里的字段

    select 字段名1,字段名1 form student;

    例如:查询student中的sname

    select sname from student;

    2,查询某个表里的字段(字段下面有重复的内容),并且显示的查询结果不显示重复的

    select distinct class from student;

    3,查询加条件

    select * from student where sno='107';

    4,查询某个字段下满足某条件的(class为95031中ssex为女的)

    select * from student where class in(95031) and ssex='女';

    5,模糊查询 

    a,查询sname第一个字是王的(_代表一个字符串)

    select * from student where sname like '王_';

    查询sname第二个字是冰的

    select * from teacher where tname like '_冰';

    b,查询sname第一个字是王的(%代表任意字符串)

    select * from student where sname like '王%';

    c,查询sname含有王的(%代表任意字符串)

    select * from student where sname like '%%';

    where中可用的运算符有:算术运算符: +  -  *  /   %

    比较运算符: >   >=   <    <=   =(等于)   <>(不等于)   ==(等于,mysql扩展),!=(不等于,mysql扩展)

    逻辑运算符: and(与)  or(或) not(非)

    6.分页查询 limit

    limit 0,2    0代表下标  2代表显示的个数

    二,说明 表名为score

    1,查询degree是60到70的

    select * from score where degree between '60' and '70';

    也可以用比较运算符这样写:select * from score where degree>60 and degree<70;

    2,查询表中degree为78和79的

    select * from score where degree='78' or degree='79';

  • 相关阅读:
    虚拟机的类加载机制
    数组
    Intellij快捷键
    Wireshark过滤器语法设置
    Git命令(转)
    Git命令
    字节码指令简介(转)
    Java异常了解
    Class类文件的结构
    垃圾收集器与内存分配策略(六)之内存分配与回收策略
  • 原文地址:https://www.cnblogs.com/wfc139/p/8902506.html
Copyright © 2020-2023  润新知