CREATE TABLE student2(
SID INT(2)AUTO_INCREMENT PRIMARY KEY NOT NULL,
Sname VARCHAR(10)NOT NULL,
Sage DATETIME NOT NULL,
Ssex ENUM(‘男’,‘女’)NOT NULL COMMENT’性别’
)DEFAULT CHARSET=utf8
INSERT INTO student2(SID,Sname,Sage,Ssex)VALUES(01,“赵雷”,‘1990-01-01 00:00:00’,‘男’),(02,“钱电”,‘1990-12-21 00:00:00’,‘男’),(03,“孙风”,‘1990-05-20 00:00:00’,‘男’),(04,“李云”,‘1990-08-06 00:00:00’,‘男’),(05,“周梅”,‘1991-12-01 00:00:00’,‘女’),(06,“吴兰”,‘1992-03-01 00:00:00’,‘女’),(07,“郑竹”,‘1989-07-01 00:00:00’,‘女’),(08,“王橘”,‘1990-01-20 00:00:00’,‘女’);
UPDATE student2 SET Sname = ‘韩梅梅’ WHERE SID = 1;
UPDATE student2 SET Ssex= ‘男’ WHERE Sage<‘1990-01-01 00:00:00’
– 1.删除需求: 把出生日期在90年之前的删除
DELETE FROM student2 WHERE CAST(Sage AS DATETIME)<‘1990-01-01 00:00:00’
SELECT DISTINCT Ssex FROM student2;
SELECT * FROM student2 WHERE Sage>‘1990’;
SELECT * FROM student2 WHERE Sage>‘1990’ AND Ssex=‘男’;
SELECT * FROM student2 WHERE Sage>‘1990’ || Ssex=‘男’;
SELECT * FROM student2 WHERE Ssex = ‘男’ ORDER BY Sage;
SELECT sid, COUNT(*) FROM student2;
SELECT SID, COUNT(*) FROM student2 WHERE Ssex=‘男’;
SELECT * FROM student2 WHERE Sname LIKE ‘赵*’;
SELECT * FROM student2 WHERE SID IN(01,03,06);
SELECT * FROM student2 WHERE Sage BETWEEN ‘1990-01-00’ AND ‘1991-01-00’;
点击查看 上一篇表单查询比这篇更基础哦
内容就到这里拉~~我是Yama 再见啦