Python 学习笔记:Intermediate SQL (2)

这里主要是整理 SQL 一些进阶的语法,方便自己不记得的时候可以快速查找。

Nested SELECT


/* general syntax */
SELECT column1, column2 FROM table1 WHERE column1 OPERATOR (SELECT column1 FROM table1 WHERE condition);

/* example 1 */
SELECT column1, column2 FROM table1 WHERE column1 < (SELECT AVG(column1) FROM table1);

/* example 2 */
SELECT column1, (SELECT MAX(column2) FROM table1) AS "Maximum" FROM table1;

Multiple Table


/* cross join */
SELECT column1, column2 FROM table1, table2;

/* inner join */
SELECT column1, column2 FROM table1, table2 WHERE table1.column3 = table2.column3;
posted @ 2021-12-09 16:43  yukiwu  阅读(43)  评论(0编辑  收藏  举报