MySQL常用查询语句Like_between_and_in

本文介绍了如何使用MySQL进行数据库操作,包括创建学生表(DDL)、插入记录(DML)以及常用的查询语句(DQL),如通过LIKE、BETWEEN和IN筛选数据。
摘要由CSDN通过智能技术生成

1.学生表DDL

CREATE TABLE `student` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '学号',
  `createDate` datetime DEFAULT NULL,
  `userName` varchar(20) DEFAULT NULL,
  `pwd` varchar(36) DEFAULT NULL,
  `phone` varchar(11) DEFAULT NULL,
  `age` tinyint(3) unsigned DEFAULT NULL,
  `sex` char(2) DEFAULT '男',
  `introduce` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

2.插入语句DML

insert into student values(0,'2024-02-25 10:10:10','赵灵儿','123',
'15612345678',16,'女','逍遥哥哥,你终于找到我了。');
insert into student values(0,'2024-02-25 10:10:10','王语嫣','123',
'15612345678',17,'女','慕容复,我和你不共戴天。');
insert into student values(0,'2024-02-25 10:10:10','龙姑娘','123',
'15612345678',22,'女','我想过过过儿过过的日子。');
insert into student values(0,'2024-02-25 10:10:10','杨过','123',
'15612345678',18,'男','一遇杨过误终身。');
insert into student values(0,'2024-02-25 10:10:10','杨逍','123',
'15612345678',27,'男','杨过跟程英的大儿子。');
insert into student (userName,age,introduce)values('黄衣女子',26,'杨过与龙姑娘的大女儿。');

3.查询语句DQL

select  * from student where userName like '杨_';
select  * from student where userName like '杨%';
select  * from student where pwd is null;
select  * from student where pwd is  not null;
select  * from student where age between 20 and 30;
select  * from student where creatDate between '2024-02-21 00:00:00' and'2024-02-25 00:00:00';
select  * from student where userName in('赵灵儿','杨过','龙姑娘');

标题:MySQL常用查询语句Like_between_and_in

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值