关系型数据库基于关系代数理论,缺点:表结构不直观,实现复杂,速度慢,优点:健壮性高,社区庞大。
SQL执行加载顺序
FROM <left_table>
ON <join_condition>
<join_type> JOIN <right_table>
WHERE <where_condition>
GROUP BY <group_by_list>
HAVING <having_condition>
SELECT
DISTINCT <select_list>
ORDER BY<order_by_condition>
LIMIT <limit_number>
如图所示: 从左到右表示从先到后
group by和join
以两个数据表为例:
product:(categoryId为外键,与category表中的categoryId关联)
* | productId | productName | categoryId | price |
---|---|---|---|---|
1 | 4 | Toyota | 2 | 100000 |
2 | 3 | Porsche | 2 | 1000000 |
3 | 2 | Adidas |