MySQL查询练习一
CREATE TABLE stu (
sid CHAR(6),
sname VARCHAR(50),
age INT,
gender VARCHAR(50)
);
INSERT INTO stu VALUES('S_1001', 'liuYi', 35, 'male');
INSERT INTO stu VALUES('S_1002', 'chenEr', 15, 'female');
INSERT INTO stu VALUES('S_1003', 'zhangSan', 95, 'male');
INSERT INTO stu VALUES('S_1004', 'liSi', 65, 'female');
INSERT INTO stu VALUES('S_1005', 'wangWu', 55, 'male');
INSERT INTO stu VALUES('S_1006', 'zhaoLiu', 75, 'female');
INSERT INTO stu VALUES('S_1007', 'sunQi', 25, 'male');
INSERT INTO stu VALUES('S_1008', 'zhouBa', 45, 'female');
INSERT INTO stu VALUES('S_1009', 'wuJiu', 85, 'male');
INSERT INTO stu VALUES('S_1010', 'zhengShi', 5, 'female');
INSERT INTO stu VALUES('S_1011', 'xxx', NULL, NULL);
================================================================
– 查询性别为女,并且年龄大于等于50的记录----------
– 查询学号为S_1001,或者姓名为liSi的记录----------
– 查询学号为S_1001,S_1002,S_1003的记录
– 查询学号不是S_1001,S_1002,S_1003的记录
– 查询年龄为null的记录
– 查询年龄在20到40之间的学生记录
– 查询性别非男的学生记录
– 查询姓名不为null的学生记录
– 查询姓名由5个字母构成的学生记录
– 查询姓名由5个字母构成,并且第5个字母为“i”的学生记录
– 查询姓名以“z”开头的学生记录
– 查询姓名中第2个字母为“i”的学生记录
– 查询姓名中包含“a”字母的学生记录