IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

mysql:dql(基本数据查询)

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

数据查询语言DQL,关键字:select、from、where等

1、单表查询

(1)查询学生表的学生的全部属性信息:

select *
from student

(2)查询全体学生的学号与姓名:

select sno,sname
from student

(3)查询的属性值可以经过计算后输出:

select sname,2019-sage
from student

(4)目标列表达式还可以是字符串常量

select sname,'Year of Birth:',birthday 
from student

99_1.png

(5)distanct关键字

--distinct:用于去除重复元组,写在select之后,属性列表之前
--一个select语句只能有一个distinct

(6)null运算

--isnull(A,B):判断A是否为null,如果为null,函数取B值,否则取A
--null参与所有运算结果仍然为null

(7)排序

  • order by 属性名列表:将查询结果按属性名排序,如果需要改变排序方式,在属性名后,desc降序,asc升序
  • 使用关键词 asc/desc,如果省略默认为升序
    select studentno,sname,email
    from student 
    order by classno desc,point desc

2、聚合函数

(1)MAX

SELECT MAX(Id) ,sname
FROM t_stu

(2)MIN

SELECT MIN(Id) ,sname
FROM t_stu

(3)count

SELECT COUNT(Id)
FROM t_stu

只要是一条记录中有一个字段不为空的字段就进行计数,而select count(字段)只会统计该字段不为null的记录条数

SELECT COUNT(*)
FROM t_stu

SELECT COUNT(*)与SELECT COUNT(1):

count(1)或括号中是其它数字、字段名,表示只选择一个字段进行查询,而count(*)表示选择所有的字段进行查询,因此, SELECT COUNT(*)的效率较低

99_2.png

99_3.png

文章永久链接:https://tech.souyunku.com/?p=22440


Warning: A non-numeric value encountered in /data/wangzhan/tech.souyunku.com.wp/wp-content/themes/dux/functions-theme.php on line 1154
赞(81) 打赏



未经允许不得转载:搜云库技术团队 » mysql:dql(基本数据查询)

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码
IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

评论 抢沙发

大前端WP主题 更专业 更方便

联系我们联系我们

觉得文章有用就打赏一下文章作者

微信扫一扫打赏

微信扫一扫打赏


Fatal error: Uncaught Exception: Cache directory not writable. Comet Cache needs this directory please: `/data/wangzhan/tech.souyunku.com.wp/wp-content/cache/comet-cache/cache/https/tech-souyunku-com/index.q`. Set permissions to `755` or higher; `777` might be needed in some cases. in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php:367 Stack trace: #0 [internal function]: WebSharks\CometCache\Classes\AdvancedCache->outputBufferCallbackHandler() #1 /data/wangzhan/tech.souyunku.com.wp/wp-includes/functions.php(5109): ob_end_flush() #2 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(303): wp_ob_end_flush_all() #3 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters() #4 /data/wangzhan/tech.souyunku.com.wp/wp-includes/plugin.php(470): WP_Hook->do_action() #5 /data/wangzhan/tech.souyunku.com.wp/wp-includes/load.php(1097): do_action() #6 [internal function]: shutdown_action_hook() #7 {main} thrown in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php on line 367