SQL Class 3 Slide-1
SQL Class 3 Slide-1
HAVING always comes after a Group by statement or for filtering aggregated values. Whereas a where clause filters
individual records, the Having the clause filters grouped records
INSERT
ALTER
UPDATE
DELETE
CREATE TABLE table_name ( CREATE TABLE users (
column1 datatype [constraints], id INT PRIMARY KEY,
column2 datatype [constraints], username VARCHAR(50) NOT NULL,
... email VARCHAR(100) UNIQUE,
columnN datatype [constraints] age INT,
); created_at DATE DEFAULT GETDATE());
Replace table_name with the name you want to give to the new table. In the
parentheses, define the columns of the table, each with its respective datatype and
optional constraints. The datatype represents the type of data the column can store,
such as INT, VARCHAR, DATE, etc. The constraints are optional and specify rules or
restrictions on the data in the column, like NOT NULL, PRIMARY KEY, UNIQUE,
DEFAULT, etc.
JOINS
INNER JOIN - Multiple Joins & Joining on multiple keys
OUTER JOIN
CROSS JOIN
INNER JOIN
LEFT JOIN
SET OPERATOR
UNION & UNION ALL
The UNION operator is used to combine the results of two or more SELECT queries into a
single result set. It removes duplicates from the combined result set, meaning that it
returns only distinct rows.
Note: UNION ALL returns duplicates
FROM Products;