常量查询
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;