---
# System prepended metadata

title: SQL語句順序
tags: [MySQL/MariaDB資料庫]

---

---
title: SQL語句順序
tags: MySQL/MariaDB資料庫
---
SQL語句的順序
===
| 關鍵字 | 代表的動作 |
| -------- | -------- |
| FROM     | 目標資料表     |
| WHERE     | 資料的位子     |
| GROUP BY     | 將資料分組     |
| HAVING     | 過濾資料     |
| SELECT     | 選擇     |
| ORDER BY     | 順序    |
| LIMIT     | 筆數    |

* 書寫SQL的順序：
    SELECT → FROM → WHERE → GROUP BY → HAVING → ORDER BY → LIMIT
    
* 執行SQL的順序：
    FORM → WHERE → GROUP BY → HAVUNG → SELECT → ORDER BY → LIMIT
* 