14、数据库查询授权操作

本文档介绍了MySQL数据库的一些查询操作,包括基于条件的查询、分组查询以及正则表达式查询。此外,还详细讲解了如何授权magedu用户,允许特定IP网段进行连接,并总结了MyISAM和InnoDB存储引擎的特点。
摘要由CSDN通过智能技术生成

1、 导入hellodb.sql生成数据库

[root@C76 ~]# mysql < hellodb_innodb.sql 

(1) 在students表中,查询年龄大于25岁,且为男性的同学的名字和年龄

MariaDB [hellodb]> select name,age from students where age>25 and gender='m'

在这里插入图片描述
(2) 以ClassID为分组依据,显示每组的平均年龄

MariaDB [hellodb]> select classid,avg(age) from students where classid is not null group by classid;

在这里插入图片描述
(3) 显示第2题中平均年龄大于30的分组及平均年龄

MariaDB [hellodb]> select classid,avg(age) as age1 from students where classid is not null group by classid having age1 >30;

在这里插入图片描述
(4) 显示以L

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值