当前位置:网站首页>[MySQL learning] 8
[MySQL learning] 8
2022-07-27 06:00:00 【m0_ sixty-seven million five hundred and ninety-five thousand n】
insert into cellphone values(null,‘vivo mobile phone ’,3600,0.88);
insert into cellphone values(null,‘ Huawei mobile phones ’,5500,0.92);
insert into cellphone values(null,‘ Meizu mobile phone ’,3400,0.95);
insert into cellphone values(null,‘ Pineapple mobile phone ’,8000,0.90);
After successfully creating the table, enter select * from cellphone; Check whether the data is inserted successfully , If shown as follows , Then our preparations are finished .

Use the alias
====
When we query data , The query column names are often not very semantic , for example , The list of mobile phones shown above is name, It's the name , What's the name ? It's not clear .
as The usage of is Old column names as New column names
Now? , We use as To define aliases , hold name Change to mobile phone name .
select name as ‘ Mobile name ’, price, discount from cellphone;

We use as Post semantic is much stronger .
Perform calculations on multiple columns
========
When we look at this table, we will find , Mobile phones have a price , 《 A big factory Java Analysis of interview questions + Back end development learning notes + The latest architecture explanation video + Practical project source code handout 》 Free open source Prestige search official account 【 Advanced programming 】 There is also a discount , Then the actual price of the mobile phone is the current price * discount , We want to check the actual price now. What should we do ? There is no actual price field in the table , At this time, we can perform arithmetic operations on multiple columns .
The format of operations performed by multiple columns is Name 1 Operator Name 2… as New column names , To enhance semantics , You can use a bracket to wrap the columns of operations .
Now? , Let's check the actual price of the mobile phone through calculation
select * ,(price * discount) as ‘ The actual price ’ from cellphone;

We use columns to calculate the current actual price , But we find that the actual price has a lot of decimals , Can we just keep 2 Decimal places ? It certainly can , Later, we can use functions to realize , I won't introduce .
边栏推荐
- Day 3. Suicidal ideation and behavior in institutions of higher learning: A latent class analysis
- GBASE 8C——SQL参考6 sql语法(10)
- Digital image processing Chapter 8 - image compression
- 7.合并与分割
- 1.PyTorch简介
- Brief analysis of application process creation process of activity
- DSGAN退化网络
- 11. Gradient derivation of perceptron
- Day 17.The role of news sentiment in oil futures returns and volatility forecasting
- GBASE 8C——SQL参考6 sql语法(1)
猜你喜欢
随机推荐
19. Up and down sampling and batchnorm
16.过拟合欠拟合
Day 17.The role of news sentiment in oil futures returns and volatility forecasting
Andorid detects GPU rendering speed and over rendering
Gbase 8C - SQL reference 6 SQL syntax (4)
为什么交叉熵损失可以用于刻画损失
Digital image processing Chapter 5 - image restoration and reconstruction
GBASE 8C——SQL参考6 sql语法(5)
pytorch模型
2021中大厂php+go面试题(1)
Gbase 8C - SQL reference 5 full text search
数字图像处理第四章——频率域滤波
MySQL查询操作索引优化实践
pytorch中交叉熵损失函数的细节
9. High order operation
数字图像处理第五章——图像复原与重建
导数、偏导数以及梯度
数字图像处理——第三章 灰度变换与空间滤波
一张照片攻破人脸识别系统:能点头摇头张嘴,网友
视觉横向课题bug1:FileNotFoundError: Could not find module ‘MvCameraControl.dll‘ (or one of it









