last

翻译:last_value()函数(已提交到MariaDB官方手册)

匿名 (未验证) 提交于 2019-12-02 22:06:11
本文为mariadb官方手册:LAST_VALUE()的译文。 原文: https://mariadb.com/kb/en/last_value/ 我提交到MariaDB官方手册的译文: https://mariadb.com/kb/zh-cn/last_value/ 语法 LAST_VALUE(expr,[expr,...]) 描述 LAST_VALUE() 对所有表达式求值,并返回最后一个值。 这在结合 使用@var:=expr为变量赋值 时很有用。例如,当你想要从updated/deleted的行中获取数据时,你无需对表做两次查询。 从MariaDB 10.2.2开始,LAST_FUNCTION可以用作为一个开窗函数 window function 。 示例 CREATE TABLE t1 (a int, b int); INSERT INTO t1 VALUES(1,10),(2,20); DELETE FROM t1 WHERE a=1 AND last_value(@a:=a,@b:=b,1); SELECT @a,@b; +------+------+ | @a | @b | +------+------+ | 1 | 10 | +------+------+ //译者补充示例 DELETE FROM t1; INSERT INTO t1 VALUES(1,10),

mysql 字符串拼接+设置null值

匿名 (未验证) 提交于 2019-12-02 22:06:11
#字符串拼接 concat(s1,s2); 将表中last_name和first_name中的字符串拼接 select concat(last_name,first_name) as 姓名 from employees; #只会修改last_name不会修改first_name SELECT first_name,last_name AS f FROM employees; #将两个列用逗号隔开并命名为out_put SELECT CONCAT(`last_name`,',',`phone_number`) AS out_put FROM employees; #ifnull 判断是否为空,如果为空则显示为0而不是null,并将列名显示为结果 SELECT IFNULL(commission_pct,0) AS 结果 FROM employees; 来源:51CTO 作者: wx5d21d5e6e5ab1 链接:https://blog.51cto.com/14437184/2434445

css---5 only-child or nth-of-type

感情迁移 提交于 2019-12-02 22:06:03
1 _nth-child系列 :nth-child(index) <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>nth-Child</title> <style type="text/css"> ul > li:nth-child(3) { background: #f00; } /* ul > li:nth-child(2n) { background: #ff0; } ul > li:nth-child(2n+1) { background: #0f0; } ul > li:nth-child(n+4) { background: #abcdef; } ul > li:nth-child(odd) { background: red; } ul > li:nth-child(even) { background: blue; } */ </style> </head> <body> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> <li>7</li> <li>8</li> <li>9</li> </ul> <hr> <div>0-1</div> <div>0-2</div> <div>0-3<

MySQL 处理重复数据

匿名 (未验证) 提交于 2019-12-02 22:02:20
有些 MySQL 数据表中可能存在重复的记录,有些情况我们允许重复数据的存在,但有时候我们也需要删除这些重复的数据。 本章节我们将为大家介绍如何防止数据表出现重复数据及如何删除数据表中的重复数据。 防止表中出现重复数据 你可以在 MySQL 数据表中设置指定的字段为 PRIMARY KEY(主键) 或者 UNIQUE(唯一) 索引来保证数据的唯一性。 让我们尝试一个实例:下表中无索引及主键,所以该表允许出现多条重复记录。 CREATE TABLE person_tbl ( first_name CHAR ( 20 ), last_name CHAR ( 20 ), sex CHAR ( 10 ) ); 如果你想设置表中字段 first_name,last_name 数据不能重复,你可以设置双主键模式来设置数据的唯一性, 如果你设置了双主键,那么那个键的默认值不能为 NULL,可设置为 NOT NULL。如下所示: CREATE TABLE person_tbl ( first_name CHAR ( 20 ) NOT NULL , last_name CHAR ( 20 ) NOT NULL , sex CHAR ( 10 ), PRIMARY KEY ( last_name , first_name ) ); 如果我们设置了唯一索引,那么在插入重复数据时,SQL

MySQL高可用之MHA安装

匿名 (未验证) 提交于 2019-12-02 21:59:42
Preface Framework Hostname IP Port Identity OS Version MySQL Version zlm2 192.168.1.101 3306 master CentOS 7.0 5.7.21 zlm3 192.168.1.102 3306 slave/mha-manager CentOS 7.0 5.7.21 null 192.168.1.200 null vip null null Procedure Downlaod the rpm package of MasterHA using below web link first: https://code.google.com/archive/p/mysql-master-ha/downloads MasterHA's wiki document. https://github.com/yoshinorim/mha4mysql-manager/wiki Configure ssh authentication between zlm2 and zlm3 from each other. 1 [root@zlm2 09:00:44 ~] 2 #ssh-keygen -t rsa 3 Generating public/private rsa key pair. 4 Enter file

嵌入式Linux2038问题内核时间time_t跟踪笔记

匿名 (未验证) 提交于 2019-12-02 21:59:42
在Linux 2.6 内核是这样子 cd include grep -irn timer_t . ./ asm -generic/posix_types .h : 94 : typedef int __kernel_timer_t; ./ asm -generic/siginfo .h : 64 : __kernel_timer_t _tid; /* timer id */ ./linux/compat .h : 523 : timer_t __user *created_timer_id); ./linux/compat .h : 524 :asmlinkage long compat_sys_timer_settime(timer_t timer_id, int flags, ./linux/compat .h : 527 :asmlinkage long compat_sys_timer_gettime(timer_t timer_id, ./linux/types .h : 34 : typedef __kernel_timer_t timer_t; ./linux/syscalls .h : 308 : timer_t __user * created_timer_id); ./linux/syscalls .h : 309 :asmlinkage long sys

linux 管道命令指南

匿名 (未验证) 提交于 2019-12-02 21:59:42
cut cut 不就是『切』吗?没错啦!这个指令可以将一段讯息的某一段给他『切』出来~ 处理的讯息是以『行』为单位喔!底下我们就来谈一谈: [dmtsai@study ~]$ cut -d '分隔字元' -f fields <==用于有特定分隔字元 [dmtsai@study ~]$ cut -c字元区间 <==用于排列整齐的讯息 选项与参数: -d :后面接分隔字元。与 -f 一起使用; -f :依据 -d 的分隔字元将一段讯息分割成为数段,用 -f 取出第几段的意思; -c :以字元(characters) 的单位取出固定字元区间; 范例一:将PATH变数取出,我要找出第五个路径。 [dmtsai@study ~]$ echo ${PATH} /usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/dmtsai/.local/bin:/home/dmtsai/bin # 1 | 2 | 3 | 4 | 5 | 6 | [dmtsai@study ~]$ echo ${PATH} | cut -d ':' -f 5 #如同上面的数字显示,我们是以『 : 』作为分隔,因此会出现/home/dmtsai/.local/bin #那么如果想要列出第3与第5呢?,就是这样: [dmtsai@study ~]$ echo ${PATH

Linux SSH 服务

匿名 (未验证) 提交于 2019-12-02 21:56:30
本篇写一些关于 Linux 网络中 SSH 服务的相关知识。 名称 IP地址 host01 192.168.28.128 host02 192.168.28.129 host03 192.168.28.130 查看 ssh 服务端口是否开启 [ root@host01 ~]# netstat - ntuap | grep sshd tcp 0 0 0.0 . 0.0 : 22 0.0 . 0.0 :* LISTEN 998 / sshd tcp6 0 0 ::: 22 :::* LISTEN 998 / sshd 默认可以使用 root 用户登录 [ root@host02 ~]# ssh root@192 . 168.28 . 128 The authenticity of host '192.168.28.128 (192.168.28.128)' can 't be established. ECDSA key fingerprint is SHA256:5GGc1rmzWwjF+ozz/PPTyLO2s6NmFHSxbzCNsLazXhY. ECDSA key fingerprint is MD5:0b:f5:62:d7:a4:1f:05:64:0b:7f:22:62:11:64:07:61. Are you sure you want to continue

Java之使用链表实现队列

匿名 (未验证) 提交于 2019-12-02 21:53:52
import java.util.Iterator; import java.util.NoSuchElementException; /** * 使用链表来实现队列 * 1.考虑结点的结构,包括当前结点的元素和模拟的指针指向下一个元素 * 2.结点的结构使用内部类来进行设计 * 3.队列的结构:队列的长度,队列的首节点,队列的尾结点 * 4.考虑队列需要的操作: * 1.使用构造函数进行初始化 * 2.判断队列是否为空 * 3.返回队列的长度 * 4.向队列尾部中添加元素 * 5.将队列首部元素删除 * 6.格式化输出 * 7.迭代器遍历 * @author WZLOVE * @create 2018-07-14 18:03 */ public class LinkedQueue<Item> implements Iterable<Item> { /** * 定义队列基本元素 */ /** * 队列的长度 */ private int n; /** * 队列的首节点 */ private Node first; /** * 队列的尾节点 */ private Node last; /** * 定义结点类 */ private class Node{ private Item item; private Node next; } /** * 使用构造方法初始化队列 *