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';

 

转载于:https://www.cnblogs.com/wfc139/p/8902506.html

  • 18
    点赞
  • 99
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值