SQL - Structured Query Language |
SQL JoinsSQL joins are used to retrieve data from two or more tables based on logical relationships between the tables. A typical join condition specifies a foreign key from one table and its associated key in the other table primary key. Logical operators are used to comparing values from the associated columns. Note: For Demo, create DEPT and EMP Tables and then INSERT sample records. --
Sample Statements -- CREATE TABLE DEPT ( Dept_Code numeric(5) Primary Key, Dept_Name varchar(50) Not Null, ) GO CREATE TABLE EMP ( Emp_Code numeric(5)Primary Key, Emp_Name varchar(50) Not Null, DOJ datetime Default GetDate(), Salary numeric(7,2) Check (salary > 1000 and Salary < 5000), Phone varchar(50), Dept_Code numeric(5) References DEPT(Dept_Code) On Delete Cascade ) GO |
* * * * *