Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions insert-update-delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#INSERT INTO Syntax

It is possible to write the INSERT INTO statement in two ways.

The first way specifies both the column names and the values to be inserted:

example-: INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);

If you are adding values for all the columns of the table, you do not need to specify the column names in the SQL query.
However, make sure the order of the values is in the same order as the columns in the table. The INSERT INTO syntax would be as follows:

example-: INSERT INTO table_name
VALUES (value1, value2, value3, ...);


#The SQL UPDATE Statement

The UPDATE statement is used to modify the existing records in a table.

UPDATE Syntax-:

example-: UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;


#The SQL DELETE Statement

The DELETE statement is used to delete existing records in a table.

DELETE Syntax-:
example-: DELETE FROM table_name WHERE condition;

47 changes: 47 additions & 0 deletions join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#JOIN
A JOIN clause is used to combine rows from two or more tables, based on a related column between them.

SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;

Different Types of SQL JOINs
Here are the different types of the JOINs in SQL:

1. (INNER) JOIN: Returns records that have matching values in both tables.
example-SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;

2. LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table.
example-SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name = table2.column_name;

3. RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table.
example-SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name = table2.column_name;

4. FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table.
example-SELECT column_name(s)
FROM table1
FULL OUTER JOIN table2
ON table1.column_name = table2.column_name
WHERE condition;

#SQL Self JOIN
A self JOIN is a regular join, but the table is joined with itself.

Self JOIN Syntax:

SELECT column_name(s)
FROM table1 T1, table1 T2
WHERE condition;

T1 and T2 are different table aliases for the same table.