查询语句示例:
查询所有学生:select * from student
;
查询指定列:select id,name from student
;
查询时给列、表指定别名:使用as关键字select id as 编号,name as 姓名 from student
;(as关键字可以省略)
给表起别名:select * from student s
;
清除重复值查询,使用关键字distinct:select distinct address from student
;(查询学生来自于哪些地方)
查询姓名、数学,将数学每个减10分:select name,math-10 from student
;
判断是否为空串:=''、<>''
判断是否为空:IS NULL,IS NOT NULL
查询address为空的学生:select * from student where address=''
;(不为空就在条件后面改就行)
查询address不为NULL的学生:select * from student address is null
;(不为空就在条件后面改就行)
in 和 like关键字查询
查询id是1或3或5的学生:select * from student where id=1 || id=3 || id=5 或 select * from student where id in (1,3,5)