SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Introduction to
SQL And PostgreSQL
Database and types of Database
• Database:-A database is an organized
collection of structured information, or
data, typically stored electronically in a
computer system
Types of databases:-
• Flat File ( like excel sheet)
• Personal database.
• Document model Databases (NoSQL)
• Relational database
Relational
Database
• A relational database is a collection of data items with
pre-defined relationships between them. These items are
organized as a set of tables with columns and rows.
• Data is stored in Tables (relations).
• These tables can be linked together.
Relational Database Management System
• MySQL, Oracle, PostgreSQL
are all RDBMS
• RDBMS allows us to interact
with the database.
SQL
• Structured Query Language.
• It is the language for talking to relational database.
• Used to create tables, insert data ,retrieve data and much more.
• SQL Queries are very similar across different database systems.
• In SQL we learn how to create a table, add entries in a table, delete
entries from a table, modify entries in a table. We will learn about
primary key , foreign key in a table.
Database Tables.
• Tables contain columns
which are also called
Fields and rows of data
which are called records.
• Each columns has a
defined data type which
defines what type of data
can be contained within
the column.
• Each row of data should
be unique.
• Each column should
contain only one value per
row.
• In a relational database,
tables can be linked
together.
• Two tables are linked by
primary key and foreign
key.
Data Types
Numeric Data Types
• Int – For whole numbers
• Numeric (P,S) – Decimal Number
• Serial – Auto Incrementing Whole Number
String Data Types
• Char(N)-Fixed Length
• Varchar (N)
• Text
Primary Key, Foreign key, Unique, Not Null and Check Constraints.
• A primary key is a column or a set of columns in a table
whose values uniquely identify a row in the table.
• A foreign key is a column or a set of columns in a table
whose values correspond to the values of the primary
key in another table.
• A unique key is a group of one or more than one fields or
columns of a table which uniquely
identify database record. A unique key is the same as a
primary key, but it can accept one null value for a table
column.
• The NOT NULL constraint enforces a column
to not accept NULL values, which means that you cannot
insert or update a record without adding a value to this
field.
• The CHECK Constraint enables a condition to check the
value being entered into a record. If the condition
evaluates to false, the record violates the constraint and
isn't entered the table
SQL Commands
SQL Commands
• Create Table:-
• Select Query:-
1.SELECT column1, column2, ...
FROM table_name;
2.SELECT * FROM table_name;
• Where:-
SELECT column1, column2, ...
FROM table_name
WHERE condition;
• Select Distinct:-
SELECT DISTINCT column1, column2, ...
FROM table_name;
• AND , OR , Not:-
1. SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND condition2 AND condition3 ...;
2. SELECT column1, column2, ...
FROM table_name
WHERE condition1 OR condition2 OR condition3 ...;
3. SELECT column1, column2, ...
FROM table_name
WHERE NOT condition;
There are also many Syntax :-
• Order by
• Insert into
• Null Values
• Delete
• IN
• Not In
• Between
• Limit
• Fetch
• Alias
There are some aggregation functions:-
• Count
• Sum
• Min
• Max
• Avg
JOIN
• A JOIN clause is used to combine rows from two or
more tables, based on a related column between them.
• In SQL there are 4 types of joins.
• INNER JOIN
• OUTER JOIN
• RIGHT JOIN
• LEFT JOIN
INNER JOIN
• 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;
LEFT JOINS
• The LEFT JOIN keyword returns all records from the left
table (table1), and the matched records from the right
table (table2). The result is NULL from the right side, if
there is no match.
Syntax:-
SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name = table2.column_name;
RIGHT JOIN
• The RIGHT JOIN keyword returns all records from the
right table (table2), and the matched records from the
left table (table1). The result is NULL from the left side,
when there is no match.
Syntax:-
SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name = table2.column_name;
FULL JOIN
• The FULL OUTER JOIN keyword returns all records when
there is a match in left (table1) or right (table2) table
records.
Syntax:-
SELECT column_name(s)
FROM table1
FULL OUTER JOIN table2
ON table1.column_name = table2.column_name
WHERE condition;
Sub Query
• A Subquery or Inner query or a Nested query is a query within
another SQL query and embedded within the WHERE clause.
• A subquery is used to return data that will be used in the main query
as a condition to further restrict the data to be retrieved.
• Subqueries can be used with the SELECT, INSERT, UPDATE, and
DELETE statements along with the operators like =, <, >, >=, <=, IN,
BETWEEN, etc.
Syntax:-
SELECT column_name FROM table_name WHERE column_name expression
operator ( SELECT COLUMN_NAME from TABLE_NAME WHERE ... );
Some other Functions
• Left and Right Sting Function
• Reverse
• Substring Function
• Replace

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Unit I Database concepts - RDBMS & ORACLE
Unit I  Database concepts - RDBMS & ORACLEUnit I  Database concepts - RDBMS & ORACLE
Unit I Database concepts - RDBMS & ORACLE
 
Introduction to spreadsheets
Introduction to spreadsheetsIntroduction to spreadsheets
Introduction to spreadsheets
 
Table naming convention
Table naming conventionTable naming convention
Table naming convention
 
Database Indexes
Database IndexesDatabase Indexes
Database Indexes
 
From Unstructured to Structured Tabular Data Using a Rule Engine
From Unstructured to Structured Tabular Data Using a Rule EngineFrom Unstructured to Structured Tabular Data Using a Rule Engine
From Unstructured to Structured Tabular Data Using a Rule Engine
 
spreadsheet
spreadsheetspreadsheet
spreadsheet
 
Access 4 U
Access 4 UAccess 4 U
Access 4 U
 
Lecture 2b lists
Lecture 2b listsLecture 2b lists
Lecture 2b lists
 
Linked list
Linked listLinked list
Linked list
 
Linked list
Linked listLinked list
Linked list
 
An introduction to spss
An introduction to spssAn introduction to spss
An introduction to spss
 
Introduction to spss
Introduction to spssIntroduction to spss
Introduction to spss
 
Index in sql server
Index in sql serverIndex in sql server
Index in sql server
 
Relational databases
Relational databasesRelational databases
Relational databases
 
Introduction to Spreadsheet Applications
Introduction to Spreadsheet ApplicationsIntroduction to Spreadsheet Applications
Introduction to Spreadsheet Applications
 
Worksheet and workbooks linking
Worksheet and workbooks linkingWorksheet and workbooks linking
Worksheet and workbooks linking
 
Cis145 Final Review
Cis145 Final ReviewCis145 Final Review
Cis145 Final Review
 
CIS145 Final Review
CIS145 Final ReviewCIS145 Final Review
CIS145 Final Review
 
The theory of relational databases
The theory of relational databasesThe theory of relational databases
The theory of relational databases
 
Excel notes
Excel notesExcel notes
Excel notes
 

Ähnlich wie Sql

Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptxSherinRappai
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptxSherinRappai1
 
Joins & constraints
Joins & constraintsJoins & constraints
Joins & constraintsVENNILAV6
 
SQL Joins Basic and Fundamentals
SQL Joins Basic and FundamentalsSQL Joins Basic and Fundamentals
SQL Joins Basic and FundamentalsPratikKhodwe1
 
Joins and Views.pptx
Joins and Views.pptxJoins and Views.pptx
Joins and Views.pptxSangitaKabi
 
SQL Data types and Constarints.pptx
SQL Data types and Constarints.pptxSQL Data types and Constarints.pptx
SQL Data types and Constarints.pptxjaba kumar
 
Java class 8
Java class 8Java class 8
Java class 8Edureka!
 
Advance database system(part 8)
Advance database system(part 8)Advance database system(part 8)
Advance database system(part 8)Abdullah Khosa
 
Tech Jam 01 - Database Querying
Tech Jam 01 - Database QueryingTech Jam 01 - Database Querying
Tech Jam 01 - Database QueryingRodger Oates
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfDraguClaudiu
 
Session 1 - Databases-JUNE 2023.pdf
Session 1 - Databases-JUNE 2023.pdfSession 1 - Databases-JUNE 2023.pdf
Session 1 - Databases-JUNE 2023.pdfSwapnilSaurav7
 
Relational database management system
Relational database management systemRelational database management system
Relational database management systemPraveen Soni
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxjainendraKUMAR55
 

Ähnlich wie Sql (20)

Sql Tutorials
Sql TutorialsSql Tutorials
Sql Tutorials
 
2..basic queries.pptx
2..basic queries.pptx2..basic queries.pptx
2..basic queries.pptx
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptx
 
Join query
Join queryJoin query
Join query
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptx
 
Joins & constraints
Joins & constraintsJoins & constraints
Joins & constraints
 
SQL
SQLSQL
SQL
 
SQL Joins Basic and Fundamentals
SQL Joins Basic and FundamentalsSQL Joins Basic and Fundamentals
SQL Joins Basic and Fundamentals
 
Joins and Views.pptx
Joins and Views.pptxJoins and Views.pptx
Joins and Views.pptx
 
SQL Data types and Constarints.pptx
SQL Data types and Constarints.pptxSQL Data types and Constarints.pptx
SQL Data types and Constarints.pptx
 
Java class 8
Java class 8Java class 8
Java class 8
 
Advance database system(part 8)
Advance database system(part 8)Advance database system(part 8)
Advance database system(part 8)
 
Tech Jam 01 - Database Querying
Tech Jam 01 - Database QueryingTech Jam 01 - Database Querying
Tech Jam 01 - Database Querying
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdf
 
SQL Join's
SQL Join'sSQL Join's
SQL Join's
 
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
 
Session 1 - Databases-JUNE 2023.pdf
Session 1 - Databases-JUNE 2023.pdfSession 1 - Databases-JUNE 2023.pdf
Session 1 - Databases-JUNE 2023.pdf
 
Relational database management system
Relational database management systemRelational database management system
Relational database management system
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
 
Introduction to SQL..pdf
Introduction to SQL..pdfIntroduction to SQL..pdf
Introduction to SQL..pdf
 

Kürzlich hochgeladen

UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spaintimesproduction05
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 

Kürzlich hochgeladen (20)

UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 

Sql

  • 2. Database and types of Database • Database:-A database is an organized collection of structured information, or data, typically stored electronically in a computer system Types of databases:- • Flat File ( like excel sheet) • Personal database. • Document model Databases (NoSQL) • Relational database
  • 3. Relational Database • A relational database is a collection of data items with pre-defined relationships between them. These items are organized as a set of tables with columns and rows. • Data is stored in Tables (relations). • These tables can be linked together.
  • 4. Relational Database Management System • MySQL, Oracle, PostgreSQL are all RDBMS • RDBMS allows us to interact with the database.
  • 5. SQL • Structured Query Language. • It is the language for talking to relational database. • Used to create tables, insert data ,retrieve data and much more. • SQL Queries are very similar across different database systems. • In SQL we learn how to create a table, add entries in a table, delete entries from a table, modify entries in a table. We will learn about primary key , foreign key in a table.
  • 6. Database Tables. • Tables contain columns which are also called Fields and rows of data which are called records. • Each columns has a defined data type which defines what type of data can be contained within the column. • Each row of data should be unique. • Each column should contain only one value per row. • In a relational database, tables can be linked together. • Two tables are linked by primary key and foreign key.
  • 7. Data Types Numeric Data Types • Int – For whole numbers • Numeric (P,S) – Decimal Number • Serial – Auto Incrementing Whole Number String Data Types • Char(N)-Fixed Length • Varchar (N) • Text
  • 8. Primary Key, Foreign key, Unique, Not Null and Check Constraints. • A primary key is a column or a set of columns in a table whose values uniquely identify a row in the table. • A foreign key is a column or a set of columns in a table whose values correspond to the values of the primary key in another table. • A unique key is a group of one or more than one fields or columns of a table which uniquely identify database record. A unique key is the same as a primary key, but it can accept one null value for a table column. • The NOT NULL constraint enforces a column to not accept NULL values, which means that you cannot insert or update a record without adding a value to this field. • The CHECK Constraint enables a condition to check the value being entered into a record. If the condition evaluates to false, the record violates the constraint and isn't entered the table
  • 10. SQL Commands • Create Table:- • Select Query:- 1.SELECT column1, column2, ... FROM table_name; 2.SELECT * FROM table_name;
  • 11. • Where:- SELECT column1, column2, ... FROM table_name WHERE condition; • Select Distinct:- SELECT DISTINCT column1, column2, ... FROM table_name; • AND , OR , Not:- 1. SELECT column1, column2, ... FROM table_name WHERE condition1 AND condition2 AND condition3 ...; 2. SELECT column1, column2, ... FROM table_name WHERE condition1 OR condition2 OR condition3 ...; 3. SELECT column1, column2, ... FROM table_name WHERE NOT condition;
  • 12. There are also many Syntax :- • Order by • Insert into • Null Values • Delete • IN • Not In • Between • Limit • Fetch • Alias
  • 13. There are some aggregation functions:- • Count • Sum • Min • Max • Avg
  • 14. JOIN • A JOIN clause is used to combine rows from two or more tables, based on a related column between them. • In SQL there are 4 types of joins. • INNER JOIN • OUTER JOIN • RIGHT JOIN • LEFT JOIN
  • 15. INNER JOIN • 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;
  • 16. LEFT JOINS • The LEFT JOIN keyword returns all records from the left table (table1), and the matched records from the right table (table2). The result is NULL from the right side, if there is no match. Syntax:- SELECT column_name(s) FROM table1 LEFT JOIN table2 ON table1.column_name = table2.column_name;
  • 17. RIGHT JOIN • The RIGHT JOIN keyword returns all records from the right table (table2), and the matched records from the left table (table1). The result is NULL from the left side, when there is no match. Syntax:- SELECT column_name(s) FROM table1 RIGHT JOIN table2 ON table1.column_name = table2.column_name;
  • 18. FULL JOIN • The FULL OUTER JOIN keyword returns all records when there is a match in left (table1) or right (table2) table records. Syntax:- SELECT column_name(s) FROM table1 FULL OUTER JOIN table2 ON table1.column_name = table2.column_name WHERE condition;
  • 19. Sub Query • A Subquery or Inner query or a Nested query is a query within another SQL query and embedded within the WHERE clause. • A subquery is used to return data that will be used in the main query as a condition to further restrict the data to be retrieved. • Subqueries can be used with the SELECT, INSERT, UPDATE, and DELETE statements along with the operators like =, <, >, >=, <=, IN, BETWEEN, etc. Syntax:- SELECT column_name FROM table_name WHERE column_name expression operator ( SELECT COLUMN_NAME from TABLE_NAME WHERE ... );
  • 20. Some other Functions • Left and Right Sting Function • Reverse • Substring Function • Replace