InterviewSolution
| 1. |
What are joins in SQL? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Answer» A join clause is a SQL command used to combine records from multiple tables or retrieve data from these tables based on the existence of a common field (column) between them. A join condition and SELECT statement can be used to join the tables. Using the SQL JOIN clause, records can be fetched from two or more tables in a database and combined. In general, they are used when users need to retrieve data from tables that contain many-to-many or one-to-many relationships between them. Example: Let's take a look at two tables. Here’s the Employee table.
Here's the Employment table.
Let us now join these two tables together using a SELECT statement, as shown below. SELECT Emp_ID, Emp_Name, Emp_No, Emp_Profile, Emp_Country FROM Employee, Employment WHERE Employee.Emp_ID = Employment.Emp_ID;Output:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||