当前位置:网站首页>SQL expression
SQL expression
2022-04-22 09:41:00 【I just learned programming】
An expression is one or more values 、 Operators and SQL Combination of functions . Every expression has a value , Through evaluation, we can get .
SQL Expressions look like mathematical formulas , They are written in query language . You can also use them to query the database for data that meets specific conditions .
grammar
Consider the following SELECT Basic syntax of statements :
SELECT column1, column2, columnN
FROM table_name
WHERE [CONDITION|EXPRESSION];
SQL There are many different types of expressions , As shown below :
Boolean expression
SQL Boolean expressions retrieve data in a single valued condition , The syntax is as follows :
SELECT column1, column2, columnN
FROM table_name
WHERE SINGLE VALUE MATCHTING EXPRESSION;
Consider the customer information table shown below :
SQL> SELECT * FROM CUSTOMERS;
+----+----------+-----+-----------+----------+
| ID | NAME | AGE | ADDRESS | SALARY |
+----+----------+-----+-----------+----------+
| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |
| 2 | Khilan | 25 | Delhi | 1500.00 |
| 3 | kaushik | 23 | Kota | 2000.00 |
| 4 | Chaitali | 25 | Mumbai | 6500.00 |
| 5 | Hardik | 27 | Bhopal | 8500.00 |
| 6 | Komal | 22 | MP | 4500.00 |
| 7 | Muffy | 24 | Indore | 10000.00 |
+----+----------+-----+-----------+----------+
7 rows in set (0.00 sec)
Here's a show SQL A simple example of a Boolean expression :
SQL> SELECT * FROM CUSTOMERS WHERE SALARY = 10000;
+----+-------+-----+---------+----------+
| ID | NAME | AGE | ADDRESS | SALARY |
+----+-------+-----+---------+----------+
| 7 | Muffy | 24 | Indore | 10000.00 |
+----+-------+-----+---------+----------+
1 row in set (0.00 sec)
Numerical expression
Numeric expressions are used to perform mathematical operations in queries . The syntax is as follows :
SELECT numerical_expression as OPERATION_NAME
[FROM table_name
WHERE CONDITION] ;
here numerical_expression For mathematical operations or any formula . Here is a description SQL A simple example of the use of numerical expressions :
SQL> SELECT (15 + 6) AS ADDITION
+----------+
| ADDITION |
+----------+
| 21 |
+----------+
1 row in set (0.00 sec)
SQL There are a series of built-in functions , for example avg()、sum()、count() etc. , These functions are used to perform aggregate data operations on a table or on specific columns in a table .
SQL> SELECT COUNT(*) AS "RECORDS" FROM CUSTOMERS;
+---------+
| RECORDS |
+---------+
| 7 |
+---------+
1 row in set (0.00 sec)
Time expression
The time expression returns the date and time of the current system :
SQL> SELECT CURRENT_TIMESTAMP;
+---------------------+
| Current_Timestamp |
+---------------------+
| 2009-11-12 06:40:23 |
+---------------------+
1 row in set (0.00 sec)
Here is a date expression :
SQL> SELECT GETDATE();;
+-------------------------+
| GETDATE |
+-------------------------+
| 2009-10-22 12:07:18.140 |
+-------------------------+
1 row in set (0.00 sec)
版权声明
本文为[I just learned programming]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220932544649.html
边栏推荐
- 跨平台编译
- Design example of large range continuous adjustable (0 ~ 45V) low power stabilized voltage power supply based on MOSFET control
- Depth first search (I): middle order traversal of binary tree (force buckle)
- Nacos
- L3-003 社交集群 (30 分) (并查集
- L3-005 dustbin distribution (30 points) (dijkstar)
- virtualbox 虚拟机使用virtio-net 运行dpdk+vpp不能收取vlan报文解决
- L3-001 凑零钱 (30 分) (剪枝 dfs
- APP优化及积分榜进阶下篇【MUI+Flask+MongoDB】
- Led by the cloud number, the revenue of Sanda shares in 2021 was 42.704 billion yuan, a year-on-year increase of 33.21%
猜你喜欢
![[age appropriate friends of interesting programming questions] (detailed explanation of the original title of leetcode)](/img/06/9f00f0a3d4105159d80b2b54fd9129.png)
[age appropriate friends of interesting programming questions] (detailed explanation of the original title of leetcode)

QT布局管理复习

APP优化及积分榜进阶下篇【MUI+Flask+MongoDB】

作文以记之 ~ 目标和

Zhezheng nail scanning code login

openlayer中,svg图片无width如何修改大小

深度优先搜索(一):二叉树的中序遍历(力扣)

在销量压力下,国产手机开始降价了,但还没有放下最后的面子

深度解析MOS管的GS波形分析-KIA MOS管

MOS tube and MOS tube driving circuit case analysis - Kia MOS tube
随机推荐
L3-003 社交集群 (30 分) (并查集
L3-004 肿瘤诊断 (30 分)(三维 bfs
leapftp:425 failed to establish connection解决方法
Beyond iterm! Known as the next generation terminal artifact, I can't put it down after using it!
L2-030 Icelander (25 points) (nearest public ancestor)
openlayer中,svg图片无width如何修改大小
JS clich é about this, constructor, prototype
跨平台编译
Online CSV to yaml tool
mysql主备配置 二进制日志问题
Softing dataFEED OPC Suite:赋予工业设备物联网连接能力
2022年熔化焊接与热切割操作证考试题模拟考试平台操作
L3-001 change (30 points) (pruning DFS)
Deep learning remote sensing scene classification data set sorting
2022-04-21 mysql-innodb存储引擎核心处理
基于MOSFET控制的大范围连续可调(0~45V) 的小功率稳压电源设计实例
WEB应用扫码获取浙政钉用户信息
Aardio - 【库】webp图片转换
SQL 数据类型
Aardio - [library] webp picture conversion