where条件子句
where条件子句
搜索的条件由一个或者多个表达式组成!结果布尔值
逻辑运算符
| 运算符 | 语法 | 描述 | 
|---|---|---|
| and && | a and b a&&b | 逻辑与,两个都为真,结果为真 | 
| or || | a or b a||b | 逻辑或,其中一个为真,则结果为真 | 
| Not ! | not a !a | 逻辑非,真为假,假为真! | 
尽量使用英文字母
-- ===================== where ============================= SELECT `studentno`,`studentresult` FROM result -- 查询考试成绩在95~100分之间 SELECT `studentno`,`studentresult` FROM result WHERE `studentresult`>=95 AND `studentresult`<=100 -- and && SELECT `studentno`,`studentresult` FROM result WHERE `studentresult`>=95 && `studentresult`<=100 -- 模糊查询(区间) SELECT `studentno`,`studentresult` FROM result WHERE `studentresult` BETWEEN 95 AND 100 -- 除了1000号学生之外的同学成绩 SELECT `studentno`,`studentresult`FROM result WHERE `studentno`!= 1000 -- != not SELECT `studentno`,`studentresult`FROM result WHERE NOT `studentno` = 1000
| 运算符 | 语法 | 描述 | 
|---|---|---|
| IS NULL | a is null | 如果操作符为null,结果为真 | 
| IS NOT NULL | a is not null | 如果操作符不为null,结果为真 | 
| BETWEEN | a between b and c | 若a在b和c之间,则结果为真 | 
| Like | a like b | SQL匹配,如果a匹配b,则结果为真 | 
| In | a in(a1,a2,a3) | 假设a在a1,或者a2...其中的某一个值中,结果为真 | 
-- ===================== 模糊查询 ============================= -- 查询姓刘的同学 -- like结合 %(代表0到任意个字符) _(一个字符) SELECT `studentno`,`studentname` FROM student WHERE `studentname` LIKE '刘%' -- 查询姓刘的同学,名字后面只有一个字的 SELECT `studentno`,`studentname` FROM student WHERE `studentname` LIKE '刘_' -- 查询姓刘的同学,名字后面只有两个字的 SELECT `studentno`,`studentname` FROM student WHERE `studentname` LIKE '刘__' -- 查询名字中间有嘉字的同学 %嘉% SELECT `studentno`,`studentname` FROM student WHERE `studentname` LIKE '%嘉%' -- ====== in (具体的一个或者多个值)==== -- 查询 1001,1002,1003号学员 SELECT `studentno`,`studentname` FROM student WHERE `studentno` IN (1001,1002,1003); -- 查询在北京的学生 SELECT `studentno`,`studentname` FROM student WHERE `address` IN ('安徽','北京'); -- =====null not null ======= -- 查询地址为空的学生 null SELECT `studentno`,`studentname` FROM student WHERE `address`='' OR `address` IS NULL -- 查询有出生日期的同学 不为空 SELECT `studentno`,`studentname` FROM student WHERE `borndate` IS NOT NULL -- 查询没有出生日期的同学 为空 SELECT `studentno`,`studentname` FROM student WHERE `borndate` IS NULL
    我的一生
第1章-废物的一生 
第50章-糟糕的婴儿 
第300章-莫欺少年穷
 第600章-莫欺中年穷 
第1000章-莫欺老年穷
 第1100章-不详的离去
 第1101章-棺材板的震动 
第1150章-盗墓贼的眼泪 
第1200章-死者为大

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号