0% found this document useful (0 votes)
9 views

Day1-Sql Basics

SQL lets you access and manipulate databases. SQL can execute queries against a database, retrieve data, insert records, update records, delete records, and more. The document covers various SQL operators like AND, OR, NOT, IN, BETWEEN, LIKE and joins.

Uploaded by

Shiny Christina
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Day1-Sql Basics

SQL lets you access and manipulate databases. SQL can execute queries against a database, retrieve data, insert records, update records, delete records, and more. The document covers various SQL operators like AND, OR, NOT, IN, BETWEEN, LIKE and joins.

Uploaded by

Shiny Christina
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

SQL

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

Larana University | 2024


2
WHAT CAN SQL DO?
SQL can execute queries against a database
SQL can retrieve data from a database
SQL can insert records in a database
SQL can update records in a database
SQL can delete records from a database
SQL can create new databases
SQL can create new tables in a database
SQL can create stored procedures in a database
SQL can create views in a database
SQL can set permissions on tables, procedures, and views
3
THE SQL AND OPERATOR
The AND operator displays a record if all the conditions are TRUE.

SYNTAX

SELECT column1, column2, ...


FROM table_name
WHERE condition1 AND condition2 AND condition3 ...;
4
THE SQL OR OPERATOR
The OR operator displays a record if any of the conditions are TRUE.

SYNTAX

SELECT column1, column2, ...


FROM table_name
WHERE condition1 OR condition2 OR condition3 ...;
5
THE NOT OPERATOR
The NOT operator is used in combination with other operators to give the
opposite result, also called the negative result

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

You might also like