查询全部表数据

1
2
#可以不按顺序
SELECT id,stuName,age,sex,gradeName FROM t_student;

img

1
SELECT * FROM t_student; 

img

查询指定表数据

1
SELECT stuName,gradeName FROM t_student; 

img

查询表数据语句:

1
2
#id为1
SELECT * FROM t_student WHERE id=1;

img

1
2
#年龄大于24
SELECT * FROM t_student WHERE age>24;

img

1
2
#年龄是212324
SELECT * FROM t_student WHERE age IN(21,23,24);

img

1
2
#年龄不是212324
SELECT * FROM t_student WHERE age NOT IN(21,23,24);

img

1
2
#年龄在2124之间的,包括
SELECT * FROM t_student WHERE age BETWEEN 21 AND 24;

img

1
2
#年龄不在2124之间的,包括
SELECT * FROM t_student WHERE age NOT BETWEEN 21 AND 24;

img