当前位置:网站首页>SQL quick query
SQL quick query
2020-11-08 16:57:00 【Irving the procedural ape】

- relational database , Based on the relational model , Use relationship ( surface ) Store the data , At the same time, the integrity constraint is defined . Common relational database systems include :Oracle、MySQL/MariaDB、SQL Server、PostgreSQL wait .
- SQL, Structured query language , Standard language for accessing and manipulating relational databases .SQL It's declarative , Is a set oriented programming language .
1、 Single table query
SELECT col1, col2 AS c2 -- Column alias FROM t; -- The basic query SELECT * FROM t; -- Query all fields SELECT col1, col2, … FROM t WHERE conditions; -- Filter conditions SELECT col1, col2, … FROM t ORDER BY col1 ASC, col2 DESC; -- Sort SELECT col1, col2, … FROM t ORDER BY col1 ASC, col2 DESC OFFSET m ROWS FETCH FIRST n ROWS ONLY; -- Limit the number of LIMIT n OFFSET m; -- Non standard implementation SELECT col1, col2, agg_fun() -- Aggregate functions FROM t GROUP BY col1, col2 -- Group summary HAVING conditions; -- Filter after grouping
2、 Multiple table joins
SELECT t1.col1, t2.col2, … FROM t1 INNER JOIN t2 ON conditions; -- Internal connection SELECT t1.col1, t2.col2, … FROM t1 LEFT JOIN t2 ON conditions; -- Left connection SELECT t1.col1, t2.col2, … FROM t1 RIGHT JOIN t2 ON conditions; -- The right connection SELECT t1.col1, t2.col2, … FROM t1 FULL JOIN t2 ON conditions; -- Full connection SELECT t1.col1, t2.col2, … FROM t1 CROSS JOIN t2 ON conditions;-- Cross connect SELECT a.col1, b.col2, … FROM t1 a -- Table alias JOIN t1 b ON conditions; -- Self join
3、 Set operations
SELECT col1, col2, … FROM t1 UNION [ALL]SELECT c1, c2, … FROM t2; -.........
版权声明
本文为[Irving the procedural ape]所创,转载请带上原文链接,感谢
边栏推荐
- 2035 we will build such a country
- Solution to cross domain problem of front end separation
- 学习记录并且简单分析
- Your random IO hard disk
- Golang 系统ping程序探测存活主机(任意权限)
- 我用 Python 找出了删除我微信的所有人并将他们自动化删除了
- 2020-11-05
- [elastic search technology sharing] - ten pictures to show you the principle of ES! Understand why to say: ES is quasi real time!
- 关于adb连接手机offline的问题解决
- Build simple business monitoring Kanban based on Alibaba cloud log service
猜你喜欢
随机推荐
IT industry salary has been far ahead! Ten years later, is the programmer still a high paying profession?
Golang ICMP协议探测存活主机
构建者模式(Builder pattern)
How to solve the conflict when JD landed on Devops platform?
We made a medical version of the MNIST dataset, and found that the common automl algorithm is not so easy to use
I used Python to find out all the people who deleted my wechat and deleted them automatically
C++的那些事儿:从电饭煲到火箭,C++无处不在
Recurrence of Apache kylin Remote Code Execution Vulnerability (cve-2020-1956)
2020-11-05
PHP生成唯一字符串
(O)ServiceManager分析(一)之BinderInternal.getContextObject
三、函数的参数
write文件一个字节后何时发起写磁盘IO
markdown使用
关于update操作并发问题
read文件一个字节实际会发生多大的磁盘IO?
学习记录并且简单分析
这几个C++的坑,一旦踩中了,加班是肯定避免不了了!
Alibaba cloud accelerates its growth and further consolidates its leading edge
Design by contract (DBC) and its application in C language