当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
猜你喜欢
构建者模式(Builder pattern)
Solution to cross domain problem of front end separation
我用 Python 找出了删除我微信的所有人并将他们自动化删除了
关于update操作并发问题
laravel8更新之维护模式改进
Huawei has an absolute advantage in the 5g mobile phone market, and the market share of Xiaomi is divided by the market survey organization
Arduino IDE搭建ESP8266开发环境,文件下载过慢解决方法 | ESP-01制作WiFi开关教程,改造宿舍灯
Liteos message queuing
VIM configuration tutorial + source code
Examples of unconventional aggregation
随机推荐
进入互联网得知道的必备法律法规有哪些?
腾讯:阿里的大中台虽好,但也不是万能的!
I used Python to find out all the people who deleted my wechat and deleted them automatically
Leancloud changes in October
WebGL 水波及焦散(刻蚀)的渲染总结
experiment
C + + opencv4.3 sift matching
LiteOS-消息队列
Liteos message queuing
AI perfume is coming. Will you buy it?
京东落地DevOps平台时爆发的冲突如何解决?
非常规聚合问题举例
Golang ICMP Protocol detects viable hosts
习题五
GopherChina 2020大会
c++ opencv4.3 sift匹配
11 important operations of Python list
experiment
(O) Analysis of service manager (1) BinderInternal.getContextObject
Tencent: Although Ali's Taichung is good, it is not omnipotent!