MySQL基础讲解 day2
Posted 西京数据分析与商业智能
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL基础讲解 day2相关的知识,希望对你有一定的参考价值。
条件查询介绍
条件查询就是在查询时给出WHERE子句,在WHERE子句中可以使用如下运算符及关键字:
=、!=、<>、<、<=、>、>=;
BETWEEN…AND;
IN(set);
IS NULL;
AND;
OR;
NOT ;SELECT * FROM stu
WHERE gender='female' AND ge<50;
SELECT * FROM stu
WHERE sid ='S_1001' OR sname='liSi';
SELECT * FROM stu
WHERE sid IN ('S_1001','S_1002','S_1003');
SELECT * FROM tab_student
WHERE s_number NOT IN ('S_1001','S_1002','S_1003');
SELECT * FROM stu
WHERE age IS NULL;
SELECT *
FROM stu
WHERE age>=20 AND age<=40;
#或者
SELECT *
FROM stu
WHERE age BETWEEN 20 AND 40;
SELECT *
FROM stu
WHERE gender!='male';
#或者
SELECT *
FROM stu
WHERE gender<>'male';
#或者
SELECT *
FROM stu
WHERE NOT gender='male';
SELECT *
FROM stu
WHERE NOT sname IS NULL;
#或者
SELECT *
FROM stu
WHERE sname IS NOT NULL;
以上是关于MySQL基础讲解 day2的主要内容,如果未能解决你的问题,请参考以下文章