Sql语句你知道多少(三)------select语句

常量查询

1.查询数字

查询记录中的数据等于某个数字

select *  from tb_Student where id=1;

查询记录中的数据在某一个区间内

select * from tb_Student where english>60 and english<90;

查询中的字段长度等于某一个值

select *  from tb_Student Len(name)=3;

2.查询字符串

字符串中本身包含单引号的情况

可以把所有的字符串包含在一个双引号内

eg:"It's a test!"

但是也可以用两个单引号表示

eg:It''s a test!

查询记录姓陈的学生

select *from tb_Student where name like '陈%';

查询字段中含有小的名字

select *from tb_Student where name like '%小%';

查询记录中含有virgree,Jacboson的记录

select *from tb_Student where name in(virgree,Jacboson);

注意事项

1.连续的两个单引号不含任何表格('');

2.查询字符串中,开始和结尾的空格都是有效的

3.like使用的数据类型char ,nchar,varchar,nvarchar datetime

3.查询日期数据

查询"1984-12-10"出生的学生

select *from tb_Student where birthday ='1984-12-10';

4.查询逻辑性的数据

select *from tb_Student where english>60;

可以配合not使用

5.查询空数据

select *from tb_Student where Score is null;

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值