当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
猜你喜欢
Learn to record and analyze
Solution of DEV-C + + unable to debug in Windows Environment
On the concurrency of update operation
read文件一个字节实际会发生多大的磁盘IO?
Welcome to offer, grade P7, face-to-face sharing, 10000 words long text to take you through the interview process
It's just right. It's the ideal state
Leancloud changes in October
Exercise 5
3、 The parameters of the function
Rabbitmq (1) - basic introduction
随机推荐
Arduino ide build esp8266 development environment, slow file download solution | esp-01 make WiFi switch tutorial, transform dormitory lights
PHP generates unique strings
基于阿里云日志服务快速打造简版业务监控看板
. net large data concurrency solution
前后端分离跨域问题解决方案
Function classification big PK! How to use sigmoid and softmax respectively?
experiment
I used Python to find out all the people who deleted my wechat and deleted them automatically
刚刚好,才是最理想的状态
框架-SPI四种模式+通用设备驱动实现-源码
Framework - SPI four modes + general device driver implementation - source code
关于update操作并发问题
Leancloud changes in October
Do these mistakes in your resume affect your annual salary of one million?
这几个C++的坑,一旦踩中了,加班是肯定避免不了了!
2020-11-05
Talk about go code coverage technology and best practices
Python 列表的11个重要操作
Hello world of rabbitmq
laravel8更新之速率限制改进