student建表DDL
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '学号',
`createDate` datetime DEFAULT NULL COMMENT '创建时间',
`userName` varchar(20) DEFAULT NULL COMMENT '用户名',
`pwd` varchar(36) DEFAULT NULL COMMENT '密码',
`phone` varchar(11) DEFAULT NULL COMMENT '手机号',
`age` tinyint(3) unsigned DEFAULT NULL COMMENT '年龄',
`sex` char(2) DEFAULT NULL COMMENT '性别',
`introduce` varchar(255) DEFAULT NULL COMMENT '简介',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
DML
INSERT INTO `student` VALUES (8, '2024-03-24 10:10:10', '盘古', '123456', '15621325410', 255, '神', '开天辟地第一人。');
INSERT INTO `student` VALUES (9, '2024-03-24 10:10:10', '女娲', '123457', '15621325410', 200, '女', '女娲造人');
INSERT INTO `student` VALUES (10, '2024-03-24 10:10:10', '伏羲', '123458', '15621325410', 225, '神', '先天八卦');
INSERT INTO `student` VALUES (11, '2024-03-24 10:10:10', '神农', '123459', '15621325410', 122, '男', '尝百草');
INSERT INTO `student` VALUES (12, '2024-03-24 10:10:10', '嫘祖', '123450', '15621325410', 145, '神', '教会百姓养蚕织布');
INSERT INTO `student` VALUES (13, '2024-03-24 10:10:10', '蚩尤', '123454', '15621325410', 255, '男', '锻造大神');
INSERT INTO `student` VALUES (14, NULL, '仓颉', NULL, NULL, 125, NULL, '中国象形文字');
DQL
#like模糊查询
select * from `student` where introduce like '%人%';
#非空查询
select * from student where pwd is null;
select * from student where pwd is not null;
#范围查询1、数据2、时间
select *from student where age between 150 and 200;
select * from student where createDate between '
2024-02-21 00:00:00' and '2024-05-12 00:00:00';
#in语句查询
select * from student where userName in ('盘古','伏羲','蚩尤');