mysql_3
日期查询:
mysql> select * from member where birthday > '1962-01-01';
mysql> select * from member order by lastname desc,birthday asc;
+----+----------+-----------+--------+------------+-------+-----+
| id | lastname | firstname | status | birthday | score | sex |
+----+----------+-----------+--------+------------+-------+-----+
| 6 | z | y | | 0000-00-00 | 60 | 0 |
| 1 | james | john | s | 1972-01-01 | 60 | 1 |
| 5 | hash | newer | n | 1922-05-01 | 60 | 1 |
| 3 | hacker | johner | s | 1952-11-01 | 100 | 0 |
| 4 | busher | packer | s | 1962-01-01 | 0 | 1 |
| 2 | bush | pack | s | 1979-01-01 | 60 | 1 |
+----+----------+-----------+--------+------------+-------+-----+
6 rows in set (0.00 sec)
mysql> select * from member order by birthday asc limit 3;
+----+----------+-----------+--------+------------+-------+-----+
| id | lastname | firstname | status | birthday | score | sex |
+----+----------+-----------+--------+------------+-------+-----+
| 6 | z | y | | 0000-00-00 | 60 | 0 |
| 5 | hash | newer | n | 1922-05-01 | 60 | 1 |
| 3 | hacker | johner | s | 1952-11-01 | 100 | 0 |
+----+----------+-----------+--------+------------+-------+-----+
3 rows in set (0.01 sec)
mysql> select * from member order by birthday asc limit 2,3;
+----+----------+-----------+--------+------------+-------+-----+
| id | lastname | firstname | status | birthday | score | sex |
+----+----------+-----------+--------+------------+-------+-----+
| 3 | hacker | johner | s | 1952-11-01 | 100 | 0 |
| 4 | busher | packer | s | 1962-01-01 | 0 | 1 |
| 1 | james | john | s | 1972-01-01 | 60 | 1 |
+----+----------+-----------+--------+------------+-------+-----+
3 rows in set (0.01 sec)
随机输出限定数量(两个)结果:抽取幸运观众什么的
mysql> select * from member order by rand() limit 2;
mysql> select 17,format(sqrt(3*3+4*4),0);
+----+-------------------------+
| 17 | format(sqrt(3*3+4*4),0) |
+----+-------------------------+
| 17 | 5 |
+----+-------------------------+
1 row in set (0.00 sec)
合并输出:
mysql> select concat(firstname,' ',lastname) from member order by rand() asc limit 2;
+--------------------------------+
| concat(firstname,' ',lastname) |
+--------------------------------+
| pack bush |
| y z |
+--------------------------------+
2 rows in set (0.00 sec)
mysql_3的更多相关文章
- keepalived+mysql双主复制高可用方案
MySQL双主复制,即互为Master-Slave(只有一个Master提供写操作),可以实现数据库服务器的热备,但是一个Master宕机后不能实现动态切换.而Keepalived通过虚拟IP,实现了 ...
- Docker 搭建pxc集群 + haproxy + keepalived 高可用(二)
上一节我们有了两个分片的pxc集群,这一节我们接着安装haproxy和keepalived的实现集群的高可用 一.先下载haproxy的镜像 [root@localhost ~]# docker pu ...
- tcpdump抓包常用命令列举
情形一.采集指定网络接口和端口的数据包 sudo tcpdump -s 0 -x -n -tttt -i bond0 port 55944 -w /tmp/mysql_tmp.tcp 情形二.采集 ...
- Docker下配置双机热备PXC集群
架构: 步骤: 1.安装centos7 ,设置宿主机IP:192.168.1.224 2.先更新yum软件管理器,再安装docker 1.yum -y update 2.yum install - ...
- docker实战练习(一)
systemctl start docker systemctl pause docker systemctl unpause docker systemctl start docker system ...
- 潭州课堂25班:Ph201805201 django 项目 第四十五课 mysql集群和负载均衡(课堂笔记)
2.使用docker安装Haproxy 一.为什么要使用数据库集群和负载均衡? 1.高可用 2.高并发 3.高性能 二.mysql数据库集群方式 三.使用docker安装PXC 1.拉取PXC镜像 d ...
- haproxy(单机)+mysql集群负载均衡
HAProxy是 七层代理 ,在使甠HAProxy后,在MySQL上 看不到Apps的源IP地址 ,看到的是HAProxy地址,而 MySQL的权限访问设置是和IP地址有关 ,这样就导致了MySQL无 ...
- MySQL多实例.md
MySQL5.7多实例配置 数据库实例1配置文件 # cat /etc/my.cnf [mysqld] datadir=/data/mysql port=3306 socket=/tmp/mysql. ...
- docker 搭建Mysql集群
docker基本指令: 更新软件包 yum -y update 安装Docker虚拟机(centos 7) yum install -y docker 运行.重启.关闭Docker虚拟机 servic ...
随机推荐
- POJ 3278 The merchant
传送门 Time Limit: 3000MS Memory Limit: 65536K Description There are N cities in a country, and there i ...
- PHP利用Filesystem函数实现操作缓存(生成,获取,删除操作)
<?php class File{ //$key 相当于缓存文件的文件名 //$value 缓存数据 private $_dir;//定义默认路径 const EXT='.txt'; publi ...
- ECSHOP管理员密码忘记了怎么办?
ECSHOP管理员密码忘记了怎么办? ECSHOP教程/ ecshop教程网(www.ecshop119.com) 2013-09-06 不小心在后台把管理员全部给清空了,闹的网站都无法登陆了?有 ...
- pthread 学习系列 case1-- 共享进程数据 VS 进程
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <pthread.h& ...
- linux下Nginx服务器安装教程
序:Nginx服务器安装总结而已,不是教程. 安装的过程中出现了一些问题,原因我的云主机是纯净版,所以很多依赖包都没有.其中安装过程中就发现perl库缺少和openssl库缺少,因此我手动安装的这两款 ...
- sql数据库批量替换dedecms内容关键字
之前写了一篇dedecms后台批量替换文章中的关键词,这边我们介绍一下用sql数据库批量替换dedecms内容关键字,当然要求你对数据库比较熟悉,修改前请自行做好备份. 1.更改文章中的内容 upda ...
- 详解JavaScript中的Url编码/解码,表单提交中网址编码
本文主要针对URI编解码的相关问题做了介绍,对Url编码中哪些字符需要编码.为什么需要编码做了详细的说明,并对比分析了Javascript 中和 编解码相关的几对函数escape / unescape ...
- @version ||= version
# -*- encoding : utf-8 -*- class InterfaceBaseController < ActionController::Base private def set ...
- k-means
参考:http://www.cnblogs.com/jerrylead/archive/2011/04/06/2006910.html k-means是无监督的聚类算法,比较简单,但包含的思想不简单, ...
- [官方说明] 为什么ES4要分成两阶段?
从ES4第一个版本发布到现在,已经有段时间了,绝大多数坛友都已经适应了ES4所带来的新封装模式,但仍有部分新人和坛友对ES4的两阶段模式带有不解或曲解.本帖将就ES4的两阶段意义做出解释说明,希望更多 ...