sql statements,operators and 
joins 
typing speed:25 
Muhammed Thanveer Melayi 
Muhammedthanveermelayi@outlook.com 
Muhammed Thanveer Danish Melayi 
Muhammed Thanveer M
• different type of statements 
1.DML 
2.DDL 
3.DCL
DML 
DML is abbreviation of Data Manipulation 
Language. It is used to retrieve, store, modify, 
delete, insert and update data in database. 
Examples: SELECT, UPDATE, INSERT 
statements
SYNTAX OF INSERT INTO 
INSERT INTO table_name (column1,column2,column3,...) 
VALUES (value1,value2,value3,...); 
INSERT INTO Customers (CustomerName, ContactName, Address, City, 
PostalCode, Country) 
VALUES ('Cardinal','Tom B. Erichsen','Skagen 
21','Stavanger','4006','Norway');
DDL 
DDL is abbreviation of Data Definition Language. It is used 
to create and modify the structure of database objects in 
database. 
Examples: CREATE, ALTER, DROP statements
SYNTAX OF CREATE 
CREATE TABLE table_name 
( 
column_name1 data_type(size), 
column_name2 data_type(size), 
column_name3 data_type(size), 
.... 
); 
CREATE TABLE Persons 
( 
PersonID int, 
LastName varchar(255), 
FirstName varchar(255), 
Address varchar(255), 
City varchar(255) 
);
DCL 
DCL is abbreviation of Data Control Language. It is used 
to create roles, permissions, and referential integrity as 
well it is used to control access to database by securing 
it. 
Examples: GRANT, REVOKE statements 
• GRANT - gives user's access privileges to database 
• REVOKE - withdraw access privileges given with the GRANT command
GRANT 
privilege_name 
ON object_name 
TO {user_name 
|PUBLIC 
• privilege_name is the access right or privilege granted to the user. 
Some of the access rights are ALL, EXECUTE, and SELECT. 
• object_name is the name of an database object like TABLE, VIEW, 
STORED PROC and SEQUENCE. 
• user_name is the name of the user to whom an access right is 
being granted. 
• PUBLIC is used to grant access rights to all users. 
• ROLES are a set of privileges grouped together. 
• WITH GRANT OPTION - allows a user to grant access rights to other 
users. 
|role_name} 
[WITH GRANT 
OPTION];
SYNTAX OF REVOKE 
REVOKE 
privilege_name 
ON object_name 
FROM {user_name 
|PUBLIC 
|role_name}
example for grant 
grant select --granting select privilege 
on emp 
to public --you can give username at the place of public 
example for revoke 
revoke select--removing select privilege 
on emp 
from public
Joins 
SQL JOIN clause is used to combine rows from two or more 
tables, based on a common field between them. 
1.inner join 
2.full join 
3.left join 
4.right join
SQL INNER JOIN Keyword 
The INNER JOIN keyword selects all rows from both tables as long as there 
is a match between the columns in both tables. 
SQL INNER JOIN Syntax 
SELECT column_name(s) 
FROM table1 
INNER JOIN table2 
ON table1.column_name=table2.column_name;
SQL FULL OUTER JOIN Keyword 
The FULL OUTER JOIN keyword returns all rows from the left table 
(table1) and from the right table (table2). 
The FULL OUTER JOIN keyword combines the result of both LEFT and 
RIGHT joins. 
SQL FULL OUTER JOIN Syntax 
SELECT column_name(s) 
FROM table1 
FULL OUTER JOIN table2 
ON table1.column_name=table2.column_name;
SQL LEFT JOIN Keyword 
The LEFT JOIN keyword returns all rows from the left table 
(table1), with the matching rows in the right table (table2). The 
result is NULL in the right side when there is no match. 
SQL LEFT JOIN Syntax 
SELECT column_name(s) 
FROM table1 
LEFT JOIN table2 
ON table1.column_name=table2.column_name;
SQL RIGHT JOIN Keyword 
The RIGHT JOIN keyword returns all rows from the right table 
(table2), with the matching rows in the left table (table1). The result 
is NULL in the left side when there is no match. 
SQL RIGHT JOIN Syntax 
SELECT column_name(s) 
FROM table1 
RIGHT JOIN table2 
ON table1.column_name=table2.column_name;
Operators 
What is an Operator in SQL? 
An operator is a reserved word or a character used primarily in an SQL 
statement's WHERE clause to perform operation(s), such as 
comparisons and arithmetic operations. 
Operators are used to specify conditions in an SQL 
statement and to serve as conjunctions for multiple 
conditions in a statement. 
• Arithmetic operators (+,*,/,-...) 
• Comparison operators (=,!=,<>,>,<,>=.......) 
• Logical operators
example for logical operators 
ALL 
The ALL operator is used to compare a value to all values in another value set. 
AND 
The AND operator allows the existence of multiple conditions in an SQL statement's WHERE clause. 
ANY 
The ANY operator is used to compare a value to any applicable value in the list according to the 
condition. 
BETWEEN 
The BETWEEN operator is used to search for values that are within a set of values, given the minimum 
value and the maximum value. 
OR 
The OR operator is used to combine multiple conditions in an SQL statement's WHERE clause. 
IS NULL 
The NULL operator is used to compare a value with a NULL value. 
UNIQUE 
The UNIQUE operator searches every row of a specified table for uniqueness (no duplicates). 
for example.... 
SELECT * FROM Products 
WHERE Price BETWEEN 10 AND 20;
THANK 
YOU
Disclaimer: This presentation is prepared by trainees of 
baabtra.com as a part of mentoring program. This is not 
official document of baabtra.com – Mentoring Partner
Want to learn more about programming or Looking to become a good programmer? 
Are you wasting time on searching so many contents online? 
Do you want to learn things quickly? 
Tired of spending huge amount of money to become a Software professional? 
Do an online course 
@ baabtra.com 
We put industry standards to practice. Our structured, activity based courses are so designed 
to make a quick, good software professional out of anybody who holds a passion for coding.
Follow us @ twitter.com/baabtra 
Like us @ facebook.com/baabtra 
Subscribe to us @ youtube.com/baabtra 
Become a follower @ slideshare.net/BaabtraMentoringPartner 
Connect to us @ in.linkedin.com/in/baabtra 
Give a feedback @ massbaab.com/baabtra 
Thanks in advance 
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us 
Emarald Mall (Big Bazar Building) 
Mavoor Road, Kozhikode, 
Kerala, India. 
Ph: + 91 – 495 40 25 550 
NC Complex, Near Bus Stand 
Mukkam, Kozhikode, 
Kerala, India. 
Ph: + 91 – 495 40 25 550 
Cafit Square, 
Hilite Business Park, 
Near Pantheerankavu, 
Kozhikode 
Start up Village 
Eranakulam, 
Kerala, India. 
Email: info@baabtra.com

Statements,joins and operators in sql by thanveer danish melayi(1)

  • 2.
    sql statements,operators and joins typing speed:25 Muhammed Thanveer Melayi Muhammedthanveermelayi@outlook.com Muhammed Thanveer Danish Melayi Muhammed Thanveer M
  • 3.
    • different typeof statements 1.DML 2.DDL 3.DCL
  • 4.
    DML DML isabbreviation of Data Manipulation Language. It is used to retrieve, store, modify, delete, insert and update data in database. Examples: SELECT, UPDATE, INSERT statements
  • 5.
    SYNTAX OF INSERTINTO INSERT INTO table_name (column1,column2,column3,...) VALUES (value1,value2,value3,...); INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country) VALUES ('Cardinal','Tom B. Erichsen','Skagen 21','Stavanger','4006','Norway');
  • 6.
    DDL DDL isabbreviation of Data Definition Language. It is used to create and modify the structure of database objects in database. Examples: CREATE, ALTER, DROP statements
  • 7.
    SYNTAX OF CREATE CREATE TABLE table_name ( column_name1 data_type(size), column_name2 data_type(size), column_name3 data_type(size), .... ); CREATE TABLE Persons ( PersonID int, LastName varchar(255), FirstName varchar(255), Address varchar(255), City varchar(255) );
  • 8.
    DCL DCL isabbreviation of Data Control Language. It is used to create roles, permissions, and referential integrity as well it is used to control access to database by securing it. Examples: GRANT, REVOKE statements • GRANT - gives user's access privileges to database • REVOKE - withdraw access privileges given with the GRANT command
  • 9.
    GRANT privilege_name ONobject_name TO {user_name |PUBLIC • privilege_name is the access right or privilege granted to the user. Some of the access rights are ALL, EXECUTE, and SELECT. • object_name is the name of an database object like TABLE, VIEW, STORED PROC and SEQUENCE. • user_name is the name of the user to whom an access right is being granted. • PUBLIC is used to grant access rights to all users. • ROLES are a set of privileges grouped together. • WITH GRANT OPTION - allows a user to grant access rights to other users. |role_name} [WITH GRANT OPTION];
  • 10.
    SYNTAX OF REVOKE REVOKE privilege_name ON object_name FROM {user_name |PUBLIC |role_name}
  • 11.
    example for grant grant select --granting select privilege on emp to public --you can give username at the place of public example for revoke revoke select--removing select privilege on emp from public
  • 12.
    Joins SQL JOINclause is used to combine rows from two or more tables, based on a common field between them. 1.inner join 2.full join 3.left join 4.right join
  • 13.
    SQL INNER JOINKeyword The INNER JOIN keyword selects all rows from both tables as long as there is a match between the columns in both tables. SQL INNER JOIN Syntax SELECT column_name(s) FROM table1 INNER JOIN table2 ON table1.column_name=table2.column_name;
  • 14.
    SQL FULL OUTERJOIN Keyword The FULL OUTER JOIN keyword returns all rows from the left table (table1) and from the right table (table2). The FULL OUTER JOIN keyword combines the result of both LEFT and RIGHT joins. SQL FULL OUTER JOIN Syntax SELECT column_name(s) FROM table1 FULL OUTER JOIN table2 ON table1.column_name=table2.column_name;
  • 15.
    SQL LEFT JOINKeyword The LEFT JOIN keyword returns all rows from the left table (table1), with the matching rows in the right table (table2). The result is NULL in the right side when there is no match. SQL LEFT JOIN Syntax SELECT column_name(s) FROM table1 LEFT JOIN table2 ON table1.column_name=table2.column_name;
  • 16.
    SQL RIGHT JOINKeyword The RIGHT JOIN keyword returns all rows from the right table (table2), with the matching rows in the left table (table1). The result is NULL in the left side when there is no match. SQL RIGHT JOIN Syntax SELECT column_name(s) FROM table1 RIGHT JOIN table2 ON table1.column_name=table2.column_name;
  • 17.
    Operators What isan Operator in SQL? An operator is a reserved word or a character used primarily in an SQL statement's WHERE clause to perform operation(s), such as comparisons and arithmetic operations. Operators are used to specify conditions in an SQL statement and to serve as conjunctions for multiple conditions in a statement. • Arithmetic operators (+,*,/,-...) • Comparison operators (=,!=,<>,>,<,>=.......) • Logical operators
  • 18.
    example for logicaloperators ALL The ALL operator is used to compare a value to all values in another value set. AND The AND operator allows the existence of multiple conditions in an SQL statement's WHERE clause. ANY The ANY operator is used to compare a value to any applicable value in the list according to the condition. BETWEEN The BETWEEN operator is used to search for values that are within a set of values, given the minimum value and the maximum value. OR The OR operator is used to combine multiple conditions in an SQL statement's WHERE clause. IS NULL The NULL operator is used to compare a value with a NULL value. UNIQUE The UNIQUE operator searches every row of a specified table for uniqueness (no duplicates). for example.... SELECT * FROM Products WHERE Price BETWEEN 10 AND 20;
  • 19.
  • 20.
    Disclaimer: This presentationis prepared by trainees of baabtra.com as a part of mentoring program. This is not official document of baabtra.com – Mentoring Partner
  • 21.
    Want to learnmore about programming or Looking to become a good programmer? Are you wasting time on searching so many contents online? Do you want to learn things quickly? Tired of spending huge amount of money to become a Software professional? Do an online course @ baabtra.com We put industry standards to practice. Our structured, activity based courses are so designed to make a quick, good software professional out of anybody who holds a passion for coding.
  • 22.
    Follow us @twitter.com/baabtra Like us @ facebook.com/baabtra Subscribe to us @ youtube.com/baabtra Become a follower @ slideshare.net/BaabtraMentoringPartner Connect to us @ in.linkedin.com/in/baabtra Give a feedback @ massbaab.com/baabtra Thanks in advance www.baabtra.com | www.massbaab.com |www.baabte.com
  • 23.
    Contact Us EmaraldMall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Cafit Square, Hilite Business Park, Near Pantheerankavu, Kozhikode Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com