java 0409 笔记内容(1)
INSERT INTO student VALUES(1,'蔺斐','男','2002-04-09',0.25);
INSERT INTO student VALUES(2,'熊大','男','1999-08-08',100);
INSERT INTO student VALUES(3,'吉吉国王','男','2009-09-09',900);
INSERT INTO student VALUES(4,'光头强','男','2009-01-01',200);
SELECT * FROM student; -- 查询表中所有数据
SELECT sname,ssex FROM student; -- 查询表中指定字段数据
SELECT sid,sname AS n,ssex AS s,birth FROM student; -- 查询时添加常量列
SELECT DISTINCT(ssex) FROM student; -- 查询学生表中有哪些性别 对性别进行去重
SELECT DISTINCT ssex FROM student; -- 去重 不可以和普通字段一起查
SELECT * FROM student WHERE ssex='男'; -- 查询表中所有男生信息
SELECT sname,ssex,money FROM student WHERE money>500;-- 查询零花钱大于500的同学
SELECT sid,sname,money FROM student WHERE ssex='男'AND money>=100; -- 查询零花钱大于100元的男生编号、姓名、零花钱
SELECT * FROM student WHERE birth>'2000' AND ssex='男'; -- 查询生日在2000年以后的男生信息
SELECT YEAR(birth) FROM student; -- 截取年份
SELECT MONTH(birth) FROM student; -- 截取月
SELECT DAY(birth) FROM student; -- 截取日
SELECT * FROM student WHERE YEAR(birth)>2000 AND ssex='男'; -- 查询生日在2000年以后的男生
SELECT * FROM student WHERE money<200 OR YEAR(birth)<2000; -- 查询零花钱小于200或者2000年以前出生的学生信息
SELECT * FROM student WHERE ssex<>'男'; -- 查询学生表中不是男生的学生信息