更新 README.md
This commit is contained in:
parent
a42d0807b4
commit
ff78076043
20
README.md
20
README.md
@ -50,23 +50,23 @@
|
|||||||
## 基礎SQL語法
|
## 基礎SQL語法
|
||||||
### 建議打開資料庫一起操作
|
### 建議打開資料庫一起操作
|
||||||
### 新增資料
|
### 新增資料
|
||||||
```
|
``` sql
|
||||||
INSERT INTO teaching_sql_2 (student_id,person_id,student_birthday) # 選擇好資料表及覽未明成
|
INSERT INTO teaching_sql_2 (student_id,person_id,student_birthday) # 選擇好資料表及覽未明成
|
||||||
Values("M11112029","C123456789","900801") #將參數按照順序放入
|
Values("M11112029","C123456789","900801") #將參數按照順序放入
|
||||||
```
|
```
|
||||||
### 更新資料
|
### 更新資料
|
||||||
```
|
```sql
|
||||||
UPDATE teaching_sql_2 SET student_birthday='890801' # 將變動的資料設置好
|
UPDATE teaching_sql_2 SET student_birthday='890801' # 將變動的資料設置好
|
||||||
WHERE student_id='M11112030'; #尋找student_id 為 M11112030 的參數
|
WHERE student_id='M11112030'; #尋找student_id 為 M11112030 的參數
|
||||||
```
|
```
|
||||||
### 刪除資料
|
### 刪除資料
|
||||||
```
|
```sql
|
||||||
DELETE FROM teaching_sql_2 # 選擇要刪除的table表
|
DELETE FROM teaching_sql_2 # 選擇要刪除的table表
|
||||||
WHERE student_id='M11112029' #刪除studen_id為M1112029
|
WHERE student_id='M11112029' #刪除studen_id為M1112029
|
||||||
```
|
```
|
||||||
### 搜尋資料(最需要花時間學的地方,常常會遇到需要串接多個table的時候)
|
### 搜尋資料(最需要花時間學的地方,常常會遇到需要串接多個table的時候)
|
||||||
#### 所有資料
|
#### 所有資料
|
||||||
```
|
```sql
|
||||||
select * FROM teaching_sql_1
|
select * FROM teaching_sql_1
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ select * FROM teaching_sql_1
|
|||||||
| M11112029| 林大偉 | EL124 |
|
| M11112029| 林大偉 | EL124 |
|
||||||
|
|
||||||
#### 指定欄位
|
#### 指定欄位
|
||||||
```
|
```sql
|
||||||
select student_name FROM teaching_sql_1
|
select student_name FROM teaching_sql_1
|
||||||
```
|
```
|
||||||
|student_name |
|
|student_name |
|
||||||
@ -89,7 +89,7 @@ select student_name FROM teaching_sql_1
|
|||||||
|
|
||||||
#### 多個指定欄位
|
#### 多個指定欄位
|
||||||
|
|
||||||
```
|
```sql
|
||||||
select student_name,student_id FROM teaching_sql_1
|
select student_name,student_id FROM teaching_sql_1
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ select student_name,student_id FROM teaching_sql_1
|
|||||||
|
|
||||||
|
|
||||||
#### 查詢符合條件式的資料
|
#### 查詢符合條件式的資料
|
||||||
```
|
```sql
|
||||||
select * FROM teaching_sql_1 WHERE student_id='M11112030'
|
select * FROM teaching_sql_1 WHERE student_id='M11112030'
|
||||||
```
|
```
|
||||||
| student_id | student_name | student_class |
|
| student_id | student_name | student_class |
|
||||||
@ -110,7 +110,7 @@ select * FROM teaching_sql_1 WHERE student_id='M11112030'
|
|||||||
|M11112030| 張威勝| EL125|
|
|M11112030| 張威勝| EL125|
|
||||||
|
|
||||||
#### 查詢符合條件式的資料(and)
|
#### 查詢符合條件式的資料(and)
|
||||||
```
|
```sql
|
||||||
select * FROM teaching_sql_1 WHERE student_id='M11112030' AND student_class='EL125' # 尋找同時符合 student_id='M11112030' 及 student_class='EL125'的資料
|
select * FROM teaching_sql_1 WHERE student_id='M11112030' AND student_class='EL125' # 尋找同時符合 student_id='M11112030' 及 student_class='EL125'的資料
|
||||||
```
|
```
|
||||||
| student_id | student_name | student_class |
|
| student_id | student_name | student_class |
|
||||||
@ -119,7 +119,7 @@ select * FROM teaching_sql_1 WHERE student_id='M11112030' AND student_class='EL
|
|||||||
|
|
||||||
#### 查詢符合條件式的資料(or)
|
#### 查詢符合條件式的資料(or)
|
||||||
|
|
||||||
```
|
```sql
|
||||||
select * FROM teaching_sql_1 WHERE student_id='M11112030' or student_class='EL124' # 尋找只要符合 student_id='M11112030' 或 student_class='EL124'的資料
|
select * FROM teaching_sql_1 WHERE student_id='M11112030' or student_class='EL124' # 尋找只要符合 student_id='M11112030' 或 student_class='EL124'的資料
|
||||||
```
|
```
|
||||||
| student_id | student_name | student_class |
|
| student_id | student_name | student_class |
|
||||||
@ -128,7 +128,7 @@ select * FROM teaching_sql_1 WHERE student_id='M11112030' or student_class='EL1
|
|||||||
|M11112029|林大偉|EL124|
|
|M11112029|林大偉|EL124|
|
||||||
|
|
||||||
#### 串接2個資料表
|
#### 串接2個資料表
|
||||||
```
|
```sql
|
||||||
SELECT teaching_sql_1.student_id, # 找尋teaching_sql_1的 student_id
|
SELECT teaching_sql_1.student_id, # 找尋teaching_sql_1的 student_id
|
||||||
teaching_sql_1.student_class, # 找尋teaching_sql_1的 student_class
|
teaching_sql_1.student_class, # 找尋teaching_sql_1的 student_class
|
||||||
teaching_sql_2.person_id # 找尋teaching_sql_2的 person_id
|
teaching_sql_2.person_id # 找尋teaching_sql_2的 person_id
|
||||||
|
Loading…
Reference in New Issue
Block a user