条件where子句

阅读量: 409 编辑

条件where子句

根据一定的条件,进行数据的查询、修改、删除

语法

[WHERE condition1 [ AND | OR ] condition2]

AND:并且,表示condition1和condition2同时满足
 OR:或者,表示condition1和condition2满足一个即可

condition
    1.精确查找 = 
    2.大于 >、 >= 
    3.小于 <、 <=
    4.不等于 <> 或 !=  
	5.IS NULL,IS NOT NULL

代码实战

代码的详细解读,可以参考视频教程

SELECT * FROM student WHERE id = 5;

SELECT * FROM student WHERE id = 5 AND username = 'zhaoliu'

SELECT * FROM student WHERE status > 0 AND status < 2;

SELECT * FROM student WHERE status <> 2;

SELECT * FROM student WHERE createAt IS NOT NULL;

UPDATE student SET createAt = NULL WHERE createAt IS NOT NULL;