当前位置:网站首页>MySQL review materials (additional) case when
MySQL review materials (additional) case when
2022-06-29 03:51:00 【Red eye Aromatherapy】

MySQL Review the information ( additional )case when
The article links
MySQL Review the information ( One )——MySQL Environmental installation
MySQL Review the information ( Two )——MySQL-DDL sentence
MySQL Review the information ( 3、 ... and )——MySQL-DML sentence
MySQL Review the information ( Four )——MySQL- Aggregate functions
MySQL Review the information ( 5、 ... and )——MySQL- Indexes
MySQL Review the information ( 6、 ... and )——MySQL- Multi table joint query
MySQL Review the information ( 7、 ... and )——MySQL- stored procedure
MySQL Review the information ( 8、 ... and )——MySQL- Business
MySQL Review the information ( Nine )——MySQL- Graphical tools use
Content of this chapter :case when Use
/*
Navicat Premium Data Transfer
Source Server : rm-bp1zq3879r28p726lco.mysql.rds.aliyuncs.com_3306
Source Server Type : MySQL
Source Server Version : 50732
Source Host : rm-bp1zq3879r28p726lco.mysql.rds.aliyuncs.com:3306
Source Schema : mytest
Target Server Type : MySQL
Target Server Version : 50732
File Encoding : 65001
Date: 28/06/2022 18:58:48
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`id` int(8) NOT NULL AUTO_INCREMENT,
`createDate` datetime(0) NOT NULL,
`userName` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`passWord` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`age` int(3) NOT NULL,
`phone` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`introduce` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `userName_index`(`userName`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of users
-- ----------------------------
INSERT INTO `users` VALUES (1, '2022-06-26 13:43:11', 'admin', '123456', 22, '15912345678', ' Like learning .');
INSERT INTO `users` VALUES (2, '2022-06-26 13:43:11', 'zhangsan', '123456', 32, '15912345678', ' I love cooking .');
INSERT INTO `users` VALUES (3, '2022-06-26 13:43:11', 'lisi', '45451', 42, '15912345678', ' I like make-up .');
INSERT INTO `users` VALUES (4, '2022-06-26 13:43:11', 'zhaoliu', '2222', 52, '15912345678', ' Like martial arts .');
INSERT INTO `users` VALUES (5, '2022-06-26 13:43:11', 'zhaoliu', '11111', 16, '15912345678', ' Like dancing .');
INSERT INTO `users` VALUES (6, '2022-06-26 13:43:11', 'zhaoliu', '123787', 27, '15912345678', ' Like to pick up girls .');
SET FOREIGN_KEY_CHECKS = 1;
test :
Direct unsigned judgment
select userName,
(
case
when sex=0 then ' Woman '
when sex=1 then ' male '
end
) sexName
from users;
Signed judgment
select userName,age,
(
case
when age<20 then ' teenagers '
when age<30 then ' youth '
else ' Prime of life '
end
) state
from usersCreate view , And query against the view
# Query and create views
create view newTableName as (
select userName,age,
(
case
when age<20 then ' teenagers '
when age<30 then ' youth '
else ' Prime of life '
end
) state
from users
);
select state ' state ',count(state) ' Number '
from newTableName GROUP BY state;Pay attention to practice .
边栏推荐
- Open source demo| you draw and I guess -- make your life more interesting
- Data collection and management [4]
- Microsecond TCP timestamp
- Mobileone: the mobile terminal only needs 1ms of high-performance backbone
- [dynamic planning] change exchange
- Data collection and management [5]
- Idea of importing point cloud map into gazebo
- Zigzag sequence traversal of binary tree [one of layered traversal methods - > preorder traversal +level]
- Which is the product with the highest interest rate of increased life insurance on the market at present?
- Data statistical analysis (SPSS) [5]
猜你喜欢

谁家的加密密钥,写死在代码里?(说的就是你)

【TcaplusDB知识库】TcaplusDB-tcapulogmgr工具介绍(二)

87.(cesium篇)cesium热力图(贴地形)

中小型企业网络的组建
![[tcapulusdb knowledge base] Introduction to tcapulusdb tcapsvrmgr tool (III)](/img/7b/8c4f1549054ee8c0184495d9e8e378.png)
[tcapulusdb knowledge base] Introduction to tcapulusdb tcapsvrmgr tool (III)

leetcode:560. 和为 K 的子数组

《运营之光3.0》全新上市——跨越时代,自我颠覆的诚意之作

迅为龙芯开发板pmon下Ejtag-设置硬件断点指令
![[interview guide] AI algorithm interview](/img/00/918608afe7f2b8e4fd89770b512b41.png)
[interview guide] AI algorithm interview
![[tcaplusdb knowledge base] view tcapdir directory server](/img/b6/f3734dfb03ec789525636335457b99.png)
[tcaplusdb knowledge base] view tcapdir directory server
随机推荐
Error: schema validation failed with the following error: the data path '' should not have other properties (projects)
Why is informatization ≠ digitalization? Finally someone made it clear
泠静的想一想自己的路
How to understand MySQL indexes?
Data statistical analysis (SPSS) [5]
智能视觉组比赛流程草案
【若依(ruoyi)】ztree初始化
MySQL Varcahr to int
Requirements analysis specification and requirements specification
[tcapulusdb knowledge base] Introduction to tcapulusdb tcapsvrmgr tool (I)
Go implements distributed locks
20款IDEA 神级插件 效率提升 30 倍,写代码必备
Grafana Getting Started tutorial
mysql varcahr 转 int
Efficientnetv2 - get smaller models and faster training with NAS, scaling, and fused mbconv
An internal error occurred during: 'Retrieving archetypes:'.
Deeply analyzing the business logic of "chain 2+1" mode
Data collection and management [12]
【资料上新】基于3568开发板的NPU开发资料全面升级
【TcaplusDB知识库】TcaplusDB技术支持介绍