当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- IT industry salary has been far ahead! Ten years later, is the programmer still a high paying profession?
- What is forsage Ethereum smart contract? What is the global decline of Ethereum
- How much faster is a server equipped with a SSD than a mechanical hard disk
- How to make a correct summary for 7 years?
- .NET 大数据量并发解决方案
- Five phases of API life cycle
- Solution to the problem of offline connection between ADB and mobile phone
- C++的那些事儿:从电饭煲到火箭,C++无处不在
- Welcome to offer, grade P7, face-to-face sharing, 10000 words long text to take you through the interview process
- LiteOS-消息队列
猜你喜欢
Learn to record and analyze
Simple process of reading pictures by QT program developed by Python
C + + things: from rice cookers to rockets, C + + is everywhere
Arduino ide build esp8266 development environment, slow file download solution | esp-01 make WiFi switch tutorial, transform dormitory lights
We made a medical version of the MNIST dataset, and found that the common automl algorithm is not so easy to use
Simulink中封装子系统
实验
CSP考试须知与各种小技巧
Do these mistakes in your resume affect your annual salary of one million?
AI perfume is coming. Will you buy it?
随机推荐
I used Python to find out all the people who deleted my wechat and deleted them automatically
Design by contract (DBC) and its application in C language
第二章编程练习
Mac环境安装Composer
佛萨奇forsage以太坊智能合约是什么?以太坊全球滑落是怎么回事
Elasticsearch learning one (basic introduction)
我用 Python 找出了删除我微信的所有人并将他们自动化删除了
Build simple business monitoring Kanban based on Alibaba cloud log service
2020-11-05
Do these mistakes in your resume affect your annual salary of one million?
Solution to the problem of offline connection between ADB and mobile phone
Huawei has an absolute advantage in the 5g mobile phone market, and the market share of Xiaomi is divided by the market survey organization
Golang ICMP Protocol detects viable hosts
浅谈,盘点历史上有哪些著名的电脑病毒,80%的人都不知道!
On DSA of OpenGL
框架-SPI四种模式+通用设备驱动实现-源码
Blockchain weekly: the development of digital currency is written into the 14th five year plan; Biden invited senior adviser of MIT digital currency program to join the presidential transition team; V
Summary: in October, more investment management strategies have come to the new overseas defi project!
AI perfume is coming. Will you buy it?
聊聊Go代码覆盖率技术与最佳实践