# 2.2. FROM

Mệnh đề **FROM** chỉ định nguồn dữ liệu mà phần còn lại của truy vấn sẽ hoạt động trên đó. Về mặt logic, mệnh đề **FROM** là nơi bắt đầu thực hiện truy vấn. Mệnh đề **FROM** có thể chứa một bảng duy nhất, sự kết hợp của nhiều bảng được nối với nhau bằng mệnh đề **JOIN** hoặc một truy vấn **SELECT** khác bên trong truy vấn con.

**<span style="mso-list: Ignore;">a)<span style="font-style: normal; font-variant: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> </span></span>Cú pháp:**

![](https://book.inetcloud.vn/uploads/images/gallery/2024-07/embedded-image-la7a8qsb.png)

<span style="font-size: 12.0pt; line-height: 115%; mso-fareast-font-family: 'Times New Roman'; mso-no-proof: yes;"> </span>

**<span style="mso-list: Ignore;">b)<span style="font-style: normal; font-variant: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> </span></span>Ví dụ:**

Chọn tất cả các cột từ bảng “**table\_name**”:

```mssql
SELECT *
FROM table_name;
```

Chọn tất cả các cột từ bảng “**table\_name**” với bí danh tn:

```mssql
SELECT tn.*
FROM table_name tn;
```

Chọn tất cả các cột từ truy vấn con:

```mssql
SELECT *
FROM (SELECT * FROM table_name);
```

Chọn tất cả các cột từ hai bảng bằng phép "**Joins**":

```mssql
 SELECT *
FROM table_name
JOIN other_table ON (table_name.key = other_table.key);
```