Day1-Sql Basics
Day1-Sql Basics
BASICS
Presented By : Shiny Christian V
1
WHAT IS SQL?
SQL stands for Structured Query Language
SQL lets you access and manipulate databases
SQL became a standard of the American National Standards
Institute (ANSI) in 1986, and of the International
Organization for Standardization (ISO) in 1987
SYNTAX
SYNTAX
SYNTAX
SELECT column1, column2, ...
FROM table_name
WHERE NOT condition;
6
THE SQL IN OPERATOR
The IN operator allows you to specify multiple values in a WHERE
clause
The IN operator is a shorthand for multiple OR conditions
SYNTAX
SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1, value2, ...);
7
THE SQL BETWEEN OPERATOR
The BETWEEN operator selects values within a given range. The values
can be numbers, text, or dates.
The BETWEEN operator is inclusive: begin and end values are included
SYNTAX
SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;
8
THE SQL LIKE OPERATOR
The LIKE operator is used in a WHERE clause to search for a specified
pattern in a column.
SYNTAX
SELECT column1, column2, ...
FROM table_name
WHERE columnN LIKE pattern;
9
THE SQL WILDCARDS
11
SQL NULL VALUES?
A field with a NULL value is a field with no value
SYNTAX
SELECT column_names
FROM table_name
WHERE column_name IS NULL;
12
THE ORDER BY OPERATOR
The ORDER BY keyword is used to sort the
result-set in ascending or descending order.
SYNTAX
SELECT column1, column2, ...
FROM table_name
ORDER BY column1, column2, ... ASC|DESC;
13
THE LIMIT OPERATOR
The LIMIT clause is used to specify the number
of records to return
SYNTAX
SELECT column_name(s)
FROM table_name
WHERE condition
LIMIT number;
14
INNER JOINS
The INNER JOIN keyword selects records that
have matching values in both tables
SYNTAX
SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;
SELF JOIN 16
SQL SELF JOIN joins the table to itself and allows comparing rows
within the same table
SYNTAX
SELECT column_name(s)
FROM table1 T1, table1 T2
WHERE condition;
MYSQL REGEXP OPERATOR 10
REGEXP operator compares the given pattern in the input string and
returns the result which is matching with the patterns.
SYNTAX:
expression REGXP pattern
15
JOINING ACROSS DATABASE
SYNTAX
USE DATABASE1
SELECT column_name(s)
FROM DATABASE2.TABLE 2
JOIN table2
ON table1.column_name = table2.column_name;
THANK YOU