Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

MS SQL Server: The from Clause in SQL Server

Understand MS SQL Server: The from Clause in SQL Server with clear explanations, practical examples, and useful tips. This updated guide covers the...

Table of Contents

MS SQL Server: The from Clause in SQL Server is easier to understand when the core ideas are paired with practical examples. The sections below explain the topic clearly, highlight useful steps, and point out details that can prevent common errors.

The SQL Server FROM clause (T-SQL) helps list the necessary tables in the SQL Server query.

FROM clause clause

 FROM bang1 
 [ { INNER JOIN 
 | LEFT OUTER JOIN 
 | RIGHT OUTER JOIN 
 | FULL OUTER JOIN } bang2 
 ON bang1.cot1 = bang2.cot1 ] 

Variable names and variable values

bang1 and bang2 - tables used in SQL statements. Two linked tables according to the principle of state1.cot1 = bang2.cot1.

Note

  • Must have at least 1 table in the FROM clause.
  • If there are 2 or more tables, these tables are typically connected by keywords INNER or OUTER. Although it is possible to connect using the old syntax in the WHERE clause, it is recommended to use the new standard with the connection rule in the FROM clause.

Example - 1 table

 SELECT * 
 FROM nhanvien 
 WHERE ten = 'Jane; 

This example uses the FROM clause to get the table of nhanvien, no other connection tables.

Example - 2 tables with INNER JOIN

 SELECT nhacungcap.nhacungcap_id, nhacungcap.nhacungcap_ten, donhang.donhang_ngay 
 FROM nhacungcap 
 INNER JOIN donhang 
 ON nhacungcap.nhacungcap_id = donhang.nhacungcap_id; 

In this example, the FROM clause gives 2 tables and donhang, connecting these two tables with INNER JOIN with nhacungcap_id column on both tables.

Next lesson: Comparison operators in SQL Server

FAQ

What should you know about fROM clause clause FROM bang1 [ { INNER JOIN | LEFT OUTER JOIN | RIGHT OUTER JOIN | FULL OUTER JOIN } bang2 ON bang1.cot1 = bang2.cot1 ] Variable names and variable values?

Bang1 and bang2 - tables used in SQL statements. Two linked tables according to the principle of state1.cot1 = bang2.cot1.

What is MS SQL Server: The from Clause in SQL Server?

The SQL Server FROM clause (T-SQL) helps list the necessary tables in the SQL Server query.

Why is MS SQL Server: The from Clause in SQL Server important?

A clear understanding of MS SQL Server: The from Clause in SQL Server helps you make informed decisions, avoid common mistakes, and use the relevant tools or techniques more effectively.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.