1、创建数据表——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;
2、插入语句——DML语句
insert into student values(0,'2024-02-25 10:10:10','盘古',
'123456','15612345678',255,'神','开天辟地第一人。');
insert into student values(0,'2024-02-25 10:10:10','女娲',
'123456','15612345678',200,'女','多次造人最终成功。');
insert into student values(0,'2024-02-25 10:10:10','伏羲',
'123456','15612345678',215,'神','先天八卦');
insert into student values(0,'2024-02-25 10:10:10','神农',
'123456','15612345678',155,'男','尝百草,死与断肠草下。');
insert into student values(0,'2024-02-25 10:10:10','嫘祖',
'123456','15612345678',115,'神','教会百姓养蚕织布');
insert into student values(0,'2024-02-25 10:10:10','蚩尤',
'123456','15612345678',155,'男','锻造大神,坐下食铁巨兽。');
insert into student (userName,age,introduce) values('仓颉',125,'中国象形文字');
3、运用各种查询——like、between、in
# 模糊查询 like,以后只要写表必写的一个sql语句
select * from student where introduce like '%,%';
#空查询 is null
select * from student where pwd is null;
#范围查询 between 小数值 and 大数值
select * from student where age between 150 and 200;
select * from student where
createDate between '2024-02-20 00:00:00' and '2024-02-24 00:00:00';
select * from student where
createDate between '2024-2-20 00:00:00' and '2024-02-24 00:00:00'
#in关键字,非必要不建议用,一般不走索引,数据量超过百万就很卡。
select * from student where userName in ('女娲','蚩尤','伏羲');
select * from student where userName not in ('女娲','蚩尤','伏羲');
标签:02,10,00,COMMENT,MYSQL,2024,student,between,kile
From: https://blog.csdn.net/m0_68047268/article/details/137102340