SQL255 给出employees表中排名为奇数行的first_name

题目来源:

给出employees表中排名为奇数行的first_name_牛客题霸_牛客网

描述

对于employees表中,输出first_name排名(按first_name升序排序)为奇数的first_name

CREATE TABLE `employees` (
`emp_no` int(11) NOT NULL,
`birth_date` date NOT NULL,
`first_name` varchar(14) NOT NULL,
`last_name` varchar(16) NOT NULL,
`gender` char(1) NOT NULL,
`hire_date` date NOT NULL,PRIMARY KEY (`emp_no`));

如,输入为:

INSERT INTO employees VALUES(10001,'1953-09-02','Georgi','Facello','M','1986-06-26');
INSERT INTO employees VALUES(10002,'1964-06-02','Bezalel','Simmel','F','1985-11-21');
INSERT INTO employees VALUES(10005,'1955-01-21','Kyoichi','Maliniak','M','1989-09-12');
INSERT INTO employees VALUES(10006,'1953-04-20','Anneke','Preusig','F','1989-06-02');

输出格式:

first
Georgi
Anneke

请你在不打乱原序列顺序的情况下,输出:按first_name排升序后,取奇数行的first_name。

如对以上示例数据的first_name排序后的序列为:Anneke、Bezalel、Georgi、Kyoichi。

则原序列中的Georgi排名为3,Anneke排名为1,所以按原序列顺序输出Georgi、Anneke。

drop table if exists  `employees` ; 
CREATE TABLE `employees` (`emp_no` int(11) NOT NULL,`birth_date` date NOT NULL,`first_name` varchar(14) NOT NULL,`last_name` varchar(16) NOT NULL,`gender` char(1) NOT NULL,`hire_date` date NOT NULL,PRIMARY KEY (`emp_no`));
INSERT INTO employees VALUES(10001,'1953-09-02','Georgi','Facello','M','1986-06-26');
INSERT INTO employees VALUES(10002,'1964-06-02','Bezalel','Simmel','F','1985-11-21');
INSERT INTO employees VALUES(10005,'1955-01-21','Kyoichi','Maliniak','M','1989-09-12');
INSERT INTO employees VALUES(10006,'1953-04-20','Anneke','Preusig','F','1989-06-02');

解决 

解决方案一:

        先用row_number()对first_name排序,再利用mod()函数取出奇数行,这样取出的行里面的first_name就是我们要的了,由于要返回的是初始的排序状态,所以我们再套一层select直接从employees表取first_name,只要这里的first_name在我们上面取出的first_name里面就好了:

select e.first_name from employees e
where e.first_name in
(select a.first_name as first_name from
(select first_name,ROW_NUMBER() over(order by first_name) as rk
from employees) a
where mod(a.rk,2)!=0);
解决方案二:
mysql> select m1.first_name from-> (select e1.first_name,count(*) as 'rowid' from-> employees e1-> left join employees e2-> on e1.first_name >= e2.first_name-> group by e1.first_name ) as m1-> where m1.rowid % 2 = 1;
+------------+
| first_name |
+------------+
| Georgi     |
| Anneke     |
+------------+
2 rows in set (0.01 sec)

以下是我解题过程: 

        在我的查询中,我使用了 JOIN 条件 e1.first_name >= e2.first_name,这意味着查询返回的结果中,e1 表中的每一行都会与 e2 表中所有满足条件的行进行连接,找出小于等于他名字的计数。连接的结果不再按照原表的顺序排列,而是根据连接条件的满足程度和其他优化因素来确定最终的顺序。 (这是gpt说的)

mysql> select e1.first_name,count(*) from-> employees e1-> join employees e2-> on e1.first_name >= e2.first_name-> group by e1.first_name;
+------------+----------+
| first_name | count(*) |
+------------+----------+
| Kyoichi    |        4 |
| Georgi     |        3 |
| Bezalel    |        2 |
| Anneke     |        1 |
+------------+----------+
4 rows in set (0.00 sec)mysql>
mysql> select e1.first_name,count(e1.first_name) from-> employees e1-> join employees e2-> on e1.first_name >= e2.first_name-> group by e1.first_name;
+------------+----------------------+
| first_name | count(e1.first_name) |
+------------+----------------------+
| Kyoichi    |                    4 |
| Georgi     |                    3 |
| Bezalel    |                    2 |
| Anneke     |                    1 |
+------------+----------------------+
4 rows in set (0.00 sec)

但是这样查出来的 数据改变了数据的顺序:

mysql> select first_name from employees; 
+------------+
| first_name |
+------------+
| Georgi     |
| Bezalel    |
| Kyoichi    |
| Anneke     |
+------------+
4 rows in set (0.00 sec)mysql> select e1.first_name from-> employees e1-> join employees e2-> on e1.first_name >= e2.first_name-> group by e1.first_name;
+------------+
| first_name |
+------------+
| Kyoichi    |
| Georgi     |
| Bezalel    |
| Anneke     |
+------------+
4 rows in set (0.00 sec)mysql> select e1.first_name from-> employees e1-> join employees e2-> on e1.first_name >= e2.first_name;
+------------+
| first_name |
+------------+
| Kyoichi    |
| Georgi     |
| Kyoichi    |
| Bezalel    |
| Georgi     |
| Kyoichi    |
| Anneke     |
| Kyoichi    |
| Bezalel    |
| Georgi     |
+------------+
10 rows in set (0.00 sec)

        为了不改变表中的数据顺序,所以我想到了左连接,把e1表当作主表,外连接的功能就是把主表中的数据全部查出来,副表中没有一条数据与之匹配上的,就用null字段代替,且分组函数自动忽略null值:

mysql> select e1.first_name from-> employees e1-> left join employees e2-> on e1.first_name >= e2.first_name;
+------------+
| first_name |
+------------+
| Georgi     |
| Georgi     |
| Georgi     |
| Bezalel    |
| Bezalel    |
| Kyoichi    |
| Kyoichi    |
| Kyoichi    |
| Kyoichi    |
| Anneke     |
+------------+
10 rows in set (0.00 sec)

mysql> select * from-> employees e1-> left join employees e2-> on e1.first_name >= e2.first_name;
+--------+------------+------------+-----------+--------+------------+--------+------------+------------+-----------+--------+------------+
| emp_no | birth_date | first_name | last_name | gender | hire_date  | emp_no | birth_date | first_name | last_name | gender | hire_date  |
+--------+------------+------------+-----------+--------+------------+--------+------------+------------+-----------+--------+------------+
|  10001 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |  10006 | 1953-04-20 | Anneke     | Preusig   | F      | 1989-06-02 |
|  10001 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |  10002 | 1964-06-02 | Bezalel    | Simmel    | F      | 1985-11-21 |
|  10001 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |  10001 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |
|  10002 | 1964-06-02 | Bezalel    | Simmel    | F      | 1985-11-21 |  10006 | 1953-04-20 | Anneke     | Preusig   | F      | 1989-06-02 |
|  10002 | 1964-06-02 | Bezalel    | Simmel    | F      | 1985-11-21 |  10002 | 1964-06-02 | Bezalel    | Simmel    | F      | 1985-11-21 |
|  10005 | 1955-01-21 | Kyoichi    | Maliniak  | M      | 1989-09-12 |  10006 | 1953-04-20 | Anneke     | Preusig   | F      | 1989-06-02 |
|  10005 | 1955-01-21 | Kyoichi    | Maliniak  | M      | 1989-09-12 |  10005 | 1955-01-21 | Kyoichi    | Maliniak  | M      | 1989-09-12 |
|  10005 | 1955-01-21 | Kyoichi    | Maliniak  | M      | 1989-09-12 |  10002 | 1964-06-02 | Bezalel    | Simmel    | F      | 1985-11-21 |
|  10005 | 1955-01-21 | Kyoichi    | Maliniak  | M      | 1989-09-12 |  10001 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |
|  10006 | 1953-04-20 | Anneke     | Preusig   | F      | 1989-06-02 |  10006 | 1953-04-20 | Anneke     | Preusig   | F      | 1989-06-02 |
+--------+------------+------------+-----------+--------+------------+--------+------------+------------+-----------+--------+------------+
10 rows in set (0.00 sec)mysql> select * from-> employees e1-> left join employees e2-> on e1.first_name >  e2.first_name;
+--------+------------+------------+-----------+--------+------------+--------+------------+------------+-----------+--------+------------+
| emp_no | birth_date | first_name | last_name | gender | hire_date  | emp_no | birth_date | first_name | last_name | gender | hire_date  |
+--------+------------+------------+-----------+--------+------------+--------+------------+------------+-----------+--------+------------+
|  10001 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |  10006 | 1953-04-20 | Anneke     | Preusig   | F      | 1989-06-02 |
|  10001 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |  10002 | 1964-06-02 | Bezalel    | Simmel    | F      | 1985-11-21 |
|  10002 | 1964-06-02 | Bezalel    | Simmel    | F      | 1985-11-21 |  10006 | 1953-04-20 | Anneke     | Preusig   | F      | 1989-06-02 |
|  10005 | 1955-01-21 | Kyoichi    | Maliniak  | M      | 1989-09-12 |  10006 | 1953-04-20 | Anneke     | Preusig   | F      | 1989-06-02 |
|  10005 | 1955-01-21 | Kyoichi    | Maliniak  | M      | 1989-09-12 |  10002 | 1964-06-02 | Bezalel    | Simmel    | F      | 1985-11-21 |
|  10005 | 1955-01-21 | Kyoichi    | Maliniak  | M      | 1989-09-12 |  10001 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |
|  10006 | 1953-04-20 | Anneke     | Preusig   | F      | 1989-06-02 |   NULL | NULL       | NULL       | NULL      | NULL   | NULL       |
+--------+------------+------------+-----------+--------+------------+--------+------------+------------+-----------+--------+------------+
7 rows in set (0.00 sec)

现在就跟这个顺序一样了: 

最终代码:

mysql> select m1.first_name from-> (select e1.first_name,count(*) as 'rowid' from-> employees e1-> left join employees e2-> on e1.first_name >= e2.first_name-> group by e1.first_name ) as m1-> where m1.rowid % 2 = 1;
+------------+
| first_name |
+------------+
| Georgi     |
| Anneke     |
+------------+
2 rows in set (0.01 sec)
改进的方案二:

方案一虽然能通过,其实并不完美,因为方案一没有问题的前提是employees 中的first_name没有重名的,如果我加了一条重名字的数据进去,就出问题了:

mysql> INSERT INTO employees VALUES(10007,'1953-09-02','Georgi','Facello','M','1986-06-26');
Query OK, 1 row affected (0.01 sec)

没执行insert操作前:

        如果你要像方案二一样通过join两张表来获得排名,那就必须去重, 要不然Georgi 为8,意味着小于等于他名字的有八个,这不就摇身一变,变成了名字最大的了吗

执行了insert操作后:

mysql> select e1.first_name,count(*) as 'rowid' from-> employees e1-> left join employees e2-> on e1.first_name >= e2.first_name-> group by e1.first_name ;
+------------+-------+
| first_name | rowid |
+------------+-------+
| Georgi     |     8 |
| Bezalel    |     2 |
| Kyoichi    |     5 |
| Anneke     |     1 |
+------------+-------+
4 rows in set (0.00 sec)

原因如下:

mysql> select * from-> employees e1-> left join employees e2-> on e1.first_name >=    e2.first_name;
+--------+------------+------------+-----------+--------+------------+--------+------------+------------+-----------+--------+------------+
| emp_no | birth_date | first_name | last_name | gender | hire_date  | emp_no | birth_date | first_name | last_name | gender | hire_date  |
+--------+------------+------------+-----------+--------+------------+--------+------------+------------+-----------+--------+------------+
|  10001 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |  10007 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |
|  10001 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |  10006 | 1953-04-20 | Anneke     | Preusig   | F      | 1989-06-02 |
|  10001 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |  10002 | 1964-06-02 | Bezalel    | Simmel    | F      | 1985-11-21 |
|  10001 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |  10001 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |
|  10002 | 1964-06-02 | Bezalel    | Simmel    | F      | 1985-11-21 |  10006 | 1953-04-20 | Anneke     | Preusig   | F      | 1989-06-02 |
|  10002 | 1964-06-02 | Bezalel    | Simmel    | F      | 1985-11-21 |  10002 | 1964-06-02 | Bezalel    | Simmel    | F      | 1985-11-21 |
|  10005 | 1955-01-21 | Kyoichi    | Maliniak  | M      | 1989-09-12 |  10007 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |
|  10005 | 1955-01-21 | Kyoichi    | Maliniak  | M      | 1989-09-12 |  10006 | 1953-04-20 | Anneke     | Preusig   | F      | 1989-06-02 |
|  10005 | 1955-01-21 | Kyoichi    | Maliniak  | M      | 1989-09-12 |  10005 | 1955-01-21 | Kyoichi    | Maliniak  | M      | 1989-09-12 |
|  10005 | 1955-01-21 | Kyoichi    | Maliniak  | M      | 1989-09-12 |  10002 | 1964-06-02 | Bezalel    | Simmel    | F      | 1985-11-21 |
|  10005 | 1955-01-21 | Kyoichi    | Maliniak  | M      | 1989-09-12 |  10001 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |
|  10006 | 1953-04-20 | Anneke     | Preusig   | F      | 1989-06-02 |  10006 | 1953-04-20 | Anneke     | Preusig   | F      | 1989-06-02 |
|  10007 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |  10007 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |
|  10007 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |  10006 | 1953-04-20 | Anneke     | Preusig   | F      | 1989-06-02 |
|  10007 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |  10002 | 1964-06-02 | Bezalel    | Simmel    | F      | 1985-11-21 |
|  10007 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |  10001 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |
+--------+------------+------------+-----------+--------+------------+--------+------------+------------+-----------+--------+------------+
16 rows in set (0.00 sec)mysql>
mysql> select e1.first_name from-> employees e1-> left join employees e2-> on e1.first_name >= e2.first_name;
+------------+
| first_name |
+------------+
| Georgi     |
| Georgi     |
| Georgi     |
| Georgi     |
| Bezalel    |
| Bezalel    |
| Kyoichi    |
| Kyoichi    |
| Kyoichi    |
| Kyoichi    |
| Kyoichi    |
| Anneke     |
| Georgi     |
| Georgi     |
| Georgi     |
| Georgi     |
+------------+
16 rows in set (0.00 sec)

我们需要联合两个字段去重:

mysql> select  distinct e1.first_name ,e2.first_name #distinct去掉重名的-> from employees e1-> left join employees e2-> on e1.first_name >= e2.first_name;
+------------+------------+
| first_name | first_name |
+------------+------------+
| Georgi     | Georgi     |
| Georgi     | Anneke     |
| Georgi     | Bezalel    |
| Bezalel    | Anneke     |
| Bezalel    | Bezalel    |
| Kyoichi    | Georgi     |
| Kyoichi    | Anneke     |
| Kyoichi    | Kyoichi    |
| Kyoichi    | Bezalel    |
| Anneke     | Anneke     |
+------------+------------+
10 rows in set (0.00 sec)
mysql> select count(*) as rowid,m1.first_name from-> (->-> select  distinct e1.first_name  , e2.first_name  as name-> from employees e1-> left join employees e2-> on e1.first_name >= e2.first_name-> ) as m1 group by m1.first_name;
+-------+------------+
| rowid | first_name |
+-------+------------+
|     3 | Georgi     |
|     2 | Bezalel    |
|     4 | Kyoichi    |
|     1 | Anneke     |
+-------+------------+
4 rows in set (0.01 sec)

最终答案:

mysql> select m2.first_name from-> (select count(*) as rowid,m1.first_name from-> (->-> select  distinct e1.first_name  , e2.first_name  as name-> from employees e1-> left join employees e2-> on e1.first_name >= e2.first_name-> ) as m1 group by m1.first_name)as m2 where m2.rowid % 2 = 1;
+------------+
| first_name |
+------------+
| Georgi     |
| Anneke     |
+------------+
2 rows in set (0.00 sec)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/825201.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

CSS transition和animation的用法和区别

Transition和Animation在CSS中都是用于实现元素状态变化的效果,但它们在用法和特性上存在明显的区别。 Transition transition是过度属性,主要强调的是元素状态的过渡效果。 它通常用于在元素的状态发生变化时,平滑地过渡到一个新的状态。…

高德地图API-鼠标点击地图获取经纬度坐标(关键操作)

效果图&#xff1a; 有了经纬度坐标&#xff0c;就可以得到城市的&#xff1a;adcode区域编码 html版本 <!doctype html> <html> <head><meta charset"utf-8"><meta http-equiv"X-UA-Compatible" content"IEedge"&g…

瞪羚企业申报要求材料

申报企业还需提供以下材料&#xff0c;并依顺序装订成册。申报材料的内容一定要能够公开的&#xff0c;不会涉及到国家安全等机密信息。 1.“瞪羚企业”认定申请书&#xff1b; 2.企业营业执照复印件&#xff1b; 3.经审计的近三年的财务报告&#xff1b; 4.近3年企业所得税…

低配置的电脑上刷新WPF DataGrid 很卡,如何优化?

要优化低配置电脑上WPF DataGrid的刷新卡顿问题&#xff0c;可以尝试以下几种方法&#xff1a; 启用虚拟化技术&#xff1a; VirtualizingStackPanel.IsVirtualizing"True" 。 WPF DataGrid支持行虚拟化&#xff0c;这意味着只有当前可见的行会被加载和渲染&#xf…

HarmonyOS NEXT中怎么理解HAR、HAP、HSP、App的关系

文章目录 一、HAR1.1 简介1.2 使用场景1.3 约束限制 二、HAP2.1 简介2.2 使用场景2.3 约束限制 三、HSP3.1 简介3.2 使用场景3.3 约束限制 四、小结 一、HAR 1.1 简介 HAR&#xff08;Harmony Archive&#xff09;是静态共享包&#xff0c;可以包含代码、C库、资源和配置文件…

backtracking Leetcode 回溯算法题

77.组合 第一个位置选择有 n 种&#xff0c;接下来每个位置只能在前面选择数字的后面选&#xff0c;所以有了 beg 参数&#xff0c;才能保持不重复 剪枝&#xff1a;res.size (n - beg 1) < k , 已有答案的长度 剩余所有未选择的个数 都小于最终答案长度了 就没有必要尝…

Unity类银河恶魔城学习记录13-1 p142 Save system源代码

Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释&#xff0c;可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili FileDataHandler.cs using System; using System.IO; using UnityEngine; p…

数据结构学习记录

数据结构 数组 & 链表 相连性 | 指向性 数组可以迅速定位到数组中某一个节点的位置 链表则需要通过前一个元素指向下一个元素&#xff0c;需要前后依赖顺序查找&#xff0c;效率较低 实现链表 // head > node1 > node2 > ... > nullclass Node {constructo…

基于springboot+vue+Mysql的社区维修平台

开发语言&#xff1a;Java框架&#xff1a;springbootJDK版本&#xff1a;JDK1.8服务器&#xff1a;tomcat7数据库&#xff1a;mysql 5.7&#xff08;一定要5.7版本&#xff09;数据库工具&#xff1a;Navicat11开发软件&#xff1a;eclipse/myeclipse/ideaMaven包&#xff1a;…

软件产品许可证书 Licence 全流程研发(使用非对称加密技术,既安全又简单)

本篇博客对应的代码地址&#xff1a; Gitee 仓库地址&#xff1a;https://gitee.com/biandanLoveyou/licence 源代码百度网盘链接: https://pan.baidu.com/s/1_ZhdcENcrk2ZuL11hWDLTQ?pwdbmxi 提取码: bmxi 1、背景介绍 公司是做软件 SAAS 服务的&#xff0c;一般来说软件部…

分析SQL中的ON后面AND条件与WHERE后AND的区别及其应用场景

引言ON条件 - 连接条件 示例1 - ON条件用于连接表示例2 - ON中多个连接条件WHERE条件 - 数据过滤 示例3 - WHERE条件应用于连接结果区别与结合使用总结 引言 在SQL查询中&#xff0c;JOIN子句的ON条件和WHERE子句的AND条件都用于筛选数据&#xff0c;但它们的应用上下文和作用方…

RabbitMQ项目实战(一)

文章目录 RabbitMQ项目实战选择客户端基础实战 前情提要&#xff1a;我们了解了消息队列&#xff0c;RabbitMQ的入门&#xff0c;交换机&#xff0c;以及核心特性等知识&#xff0c;现在终于来到了激动人心的项目实战环节&#xff01;本小节主要介绍通过Spring Boot RabbitMQ S…

AppsFlyer 接入更新

SDK文档 最新的 SDK 已经支持了 UPM 的接入方式&#xff0c;直接输入链接就可以安装好&#xff0c; 只需要 resolve 通过然后就可以使用了。

盒子模型和圆角边框的属性

一、标准盒子模型 content padding border margin 定义 width 和 height 时&#xff0c;参数值不包括 border 和 padding 二、怪异盒子模型 能不能实现怪异盒子模型全看属性 box-sizing&#xff0c;box-sizing 属性的取值可以为 content-box 或 border-box。 content-b…

CentOS 7 中时间快了 8 小时

1.查看系统时间 1.1 timeZone显示时区 [adminlocalhost ~]$ timedatectlLocal time: Mon 2024-04-15 18:09:19 PDTUniversal time: Tue 2024-04-16 01:09:19 UTCRTC time: Tue 2024-04-16 01:09:19Time zone: America/Los_Angeles (PDT, -0700)NTP enabled: yes NTP synchro…

DRF分页接口

DRF分页接口 目录 DRF分页接口PageNumberPagination&#xff08;基本分页类&#xff09;LimitOffsetPagination&#xff08;偏移分类)CursorPagination&#xff08;游标分页&#xff09; 实战 PageNumberPagination&#xff08;基本分页类&#xff09; 特点 基于页码的分页方式…

CS信息系统建设和服务能力评估申报知识点

代科技快速发展&#xff0c;云计算、大数据、物联网、移动互联网等新一代信息技术发展迅速&#xff0c;信息化服务模式正经历着重大的变化。而CS信息系统建设和服务能力评估是反映信息系统建设和服务提供者的能力水平的一个证书&#xff0c;现在许多企业都在办理这个资质。那么…

2021年全国大学生电子设计竞赛D题——基于互联网的摄像测量系统(三)

13 测试方案和测量结果 测量一个边长为1米的正方形&#xff0c;取三个顶点分别作为O、A、B点。 在O点上方&#xff0c;用细线悬挂激光笔&#xff0c;激光笔常亮向下指示&#xff0c;静止时激光笔的光点和O点重合。 将两个D8M摄像头子卡插到DE10-Nano开发板上&#xff0c;放…

对象生命周期:Transient(瞬态)、Scoped(范围)、Singleton(单例)

在对象生命周期和依赖注入&#xff08;DI&#xff09;的上下文中&#xff0c;特别是在使用如Microsoft.Extensions.DependencyInjection&#xff08;.NET Core的DI容器&#xff09;等框架时&#xff0c;对象的生命周期通常被划分为几个不同的类型&#xff1a;Transient&#xf…

MySQL Linux环境安装部署

目录 1、mysql安装包下载 2、安装mysql服务 3、启动mysql服务 4、登录mysql服务 1、mysql安装包下载 1、查看centos的版本 cat /etc/redhat-release 2、进入官网地址下载对应系统版本的安装包 地址&#xff1a;MySQL :: Download MySQL Yum Repository 2、安装mysql服务 …