当前位置:网站首页>MySQL tutorial 68-as setting alias
MySQL tutorial 68-as setting alias
2022-07-25 15:57:00 【51CTO】
For the convenience of inquiry , MySQL Provides AS Keyword to specify aliases for tables and fields . This section mainly explains how to specify an alias for tables and fields .
Specify an alias for the table
When the table name is very long or some special queries are executed , For ease of operation , You can specify an alias for the table , Use this alias instead of the original name of the table .
The basic syntax format for specifying aliases for tables is :
The meanings of the clauses are as follows :
-
< Table name >: The name of the data table stored in the database . -
< Alias >: The new name of the table specified when querying . -
AS Keywords can be omitted , After omitting, you need to separate the table name and alias with spaces .
Be careful : The alias of a table cannot have the same name as other tables in this database . The alias of a field cannot have the same name as other fields in the table . Field aliases cannot be used in conditional expressions , Otherwise “ERROR 1054 (42S22): Unknown column” Such error message .
example 1
The following is tb_students_info Table specifying aliases stu,SQL Statement and run results are as follows .
Specify an alias for the field
In the use of SELECT Statement to query data ,MySQL It will show each SELECT Specify the output fields later . Sometimes in order to display the results more intuitively , We can specify an alias for the field .
The basic syntax format for specifying an alias for a field is :
among , The grammatical meaning of each clause is as follows :
-
< Field name >: The name defined for the field in the data table . -
< Field alias >: Field new name . -
AS Keywords can be omitted , If omitted, you need to separate the field name and alias with spaces .
example 2
Inquire about tb_students_info surface , by name Specify alias student_name, by age Specify alias student_age,SQL Statement and run results are as follows .
边栏推荐
- Window system black window redis error 20creating server TCP listening socket *: 6379: listen: unknown error19-07-28
- Zhaoqi Kechuang high-level innovation and Entrepreneurship Talent Service Platform at home and abroad, mass entrepreneurship and innovation achievement transformation platform
- Okaleido上线聚变Mining模式,OKA通证当下产出的唯一方式
- LeetCode - 362 敲击计数器(设计)
- BSC智能链合约模式系统开发详情
- HDD Hangzhou station · harmonyos technical experts share the features of Huawei deveco studio
- 哪里有搭建flink cdc抽mysql数的demo?
- Gary Marcus: 学习语言比你想象的更难
- Wechat applet
- 【IJCAI 2022】参数高效的大模型稀疏训练方法,大幅减少稀疏训练所需资源
猜你喜欢
![Beyond compare 4 realizes class file comparison [latest]](/img/ab/4babd7d4ee4ea132a6039858dd6451.png)
Beyond compare 4 realizes class file comparison [latest]

Baseband simulation system experiment of 4pam in Gaussian channel and Rayleigh channel

Okaleido上线聚变Mining模式,OKA通证当下产出的唯一方式

Leetcode - 232 realize queue with stack (design double stack to realize queue)

IDEA—点击文件代码与目录自动同步对应

华为2023届提前批预热开始!左 神的程序代码面试指南终派上用场

Huawei 2023 starts to warm up in advance! Zuo Shen's program code interview guide comes in handy

LeetCode - 359 日志速率限制器 (设计)

Understand "average load"
SQL cultivation manual from scratch - practical part
随机推荐
Zhaoqi Kechuang high-quality overseas returnee talent entrepreneurship and innovation service platform, online live broadcast Roadshow
Leetcode - 677 key value mapping (Design)*
30 lines write the concurrency tool class yourself (semaphore, cyclicbarrier, countdownlatch)
Zhaoqi Kechuang high-level innovation and Entrepreneurship Talent Service Platform at home and abroad, mass entrepreneurship and innovation achievement transformation platform
MySQL - user and permission control
How to realize page inclusion
Gary marcus: learning a language is more difficult than you think
Pytoch learning notes -- Summary of common functions 2
Window system black window redis error 20creating server TCP listening socket *: 6379: listen: unknown error19-07-28
【莎士比亚:保持做人的乐趣】
MySQL教程67-使用DISTINCT过滤重复数据
Ml image depth learning and convolution neural network
Huawei 2023 starts to warm up in advance! Zuo Shen's program code interview guide comes in handy
Data system partition design - Request Routing
Pytoch learning notes advanced_ CNN (using perception_module) implements MNIST dataset classification - (comments and results)
微信小程序
Beyond compare 4 realizes class file comparison [latest]
Endnote add Chinese gbt7714 style how to quote documents in word
Data system partition design - partition rebalancing
「数字安全」警惕 NFT的七大骗局