SlideShare a Scribd company logo
SQLStructured Query Language
SQL-Create tableCreate table table_name(column_name1 datatype, column_name2 datatype……)Eg:create table example (id int ,name varchar(10),address varchar(10))Msg:Command(s) completed successfully.
SQL-Insert ValuesInsert into table_name(column1,column2,…..)values(values1,values2,…)Eg:insert into example (id,name,address) values(123,'xxxx','yyyyy')Msg:(1 row(s) affected)
SQL-Select Commandselect *from exampleId     name  address123	xxxxyyyyy456	jjjjrrrr456	iiiinnnn567	eeeeffff
SQL-Alter CommandAlter table table_name add or drop column_namedatatypeEg: alter table example add mobilenointMsg: Command(s) completed successfully.Id     name address  mobileno123	xxxxyyyyy     NULL456	jjjjrrrr	      NULL888	iiiinnnn	      NULL567	eeeeffff	      NULL
SQL-Update CommandUpdate table_name set column_name=new value where column_name=any valueEg: Update example set id=888 where name='iiii‘Msg: (1 row(s) affected)Id      name address123	xxxxyyyyy456	jjjjrrrr888	iiiinnnn567	eeeeffff
SQL-Delete CommandDelete  table_name where conditionEg: delete example where id=888Msg: (1 row(s) affected)Id    name address mobileno123	xxxxyyyyy     NULL456	jjjjrrrr         NULL567	eeeeffff	     NULL
SQL-Drop CommandDrop table table_nameEg: drop table exampleMsg:Command(s) completed successfully.
SQL-Primary Key & Foreign Key CREATE TABLE table_name (column1 datatype null/not null, column2 datatype null/not null,...CONSTRAINT constraint_namePRIMARY KEY (column1, column2, . column_n));CREATE TABLE table_name (column1 datatype,  column2 datatype, column3 datatype,  Primary Key (column_any), Foreign Key (Column_any) references Table_any(datatype));
SQL-Primary Key & foreign Keycreate table example (id intprimary key,namevarchar(10),address varchar(10))A primary key is used to unique and Not Null identify each row in the table.create table example2 (salary int,expamountint, id int references example(id))A foreign key is a referential constraint between two tables. 
SQL-Primary Key & Foreign Key Id     name address    123	rrrrtttt369	klkliooo456	iiiihhhh7889	wswswewwSalary   expamount id10000	4235	788912369	8526	45612369	865	  45665894	12589	123Example (primary Key tale)Example2 (Foreign Key tale)
SQL-DISTINCTselect distinct address from exaddressioioklkkyuyu
SQL-Primary Key & Foreign Key select name,address,salary from example e,example2 e2 where e.id=e2.idO/PName address    salarywswsweww	10000iiiihhhh	12369iiiihhhh 	12369rrrrtttt	          65894
SQL-BETWEEN & COUNTSELECT "column_name“ FROM "table_name"WHERE "column_name" BETWEEN 'value1' AND 'value2‘select id from ex where id between 100 and 500ID123456SELECT COUNT("column_name") FROM "table_name“select count(id)'No Of Records' from exNo Of Records4
SQL-Connection Stringstring strcon = "Data Source=172.16.0.1;Initial Catalog=BatchThree;User ID=magnum;Password=Magnum";SqlConnectionsqlcon = new SqlConnection(strcon);sqlcon.Open();stringstrsql = "insert into datab values	('" + txtmarks1.Text + "','" + txtmarks2.Text + "','" + txtmarks3.Text + "','" + txtname.Text + "')";SqlCommandcmd = new SqlCommand(strsql, sqlcon);cmd.CommandType = CommandType.Text;cmd.ExecuteNonQuery();sqlcon.Close();
SQL-Connection String
SQL-Connection String
SQL-Connection String
SQL-Stored Procedurecreate procedure proexample(@id int,@namevarchar(10),@address varchar(10)) as insert into example(id,name,address) values (@id,@name,@address)Command(s) completed successfully.exec proexample 666,'hghg','yuyu’(1 row(s) affected)
SQL-Stored Procedureselect *from exampleId    name address123	rrrrtttt369	klkliooo456	iiiihhhh666	hghgyuyu7889	wswsweww
SQL-JOINSSQL joins are used to query data from two or more tables, based on a relationship between certain columns in these tablesInner JoinLeft JoinRight JoinFull Join
SQL-INNER JOINThe INNER JOIN keyword return rows when there is at least one match in both tables.SELECT column_name(s)FROM table_name1INNER JOIN table_name2ON table_name1.column_name=table_name2.column_name
SQL-INNER JOINselect name,address,salary from example inner join example2 on example.id=example2.id order by nameName address   salaryiiiihhhh	12369iiiihhhh	12369rrrrtttt	          65894Wswsweww	10000
SQL-LEFT JOINThe LEFT JOIN keyword returns all rows from the left table (table_name1), even if there are no matches in the right table (table_name2)SELECT column_name(s)FROM table_name1LEFT JOIN table_name2ON table_name1.column_name=table_name2.column_name
SQL_LEFT JOINselect name,address,salary from example left join example2 on example.id=example2.id order by nameName  address   salaryhghgyuyu	NULLiiiihhhh	12369iiiihhhh	12369klkliooo	           NULLrrrrtttt      	65894wswsweww         10000
SQL-RIGHT JOINThe RIGHT JOIN keyword returns all the rows from the right table (table_name2), even if there are no matches in the left table (table_name1)SELECT column_name(s)FROM table_name1RIGHT JOIN table_name2ON table_name1.column_name=table_name2.column_name
SQL_RIGHT JOINselect name,address,salary from example right join example2 on example.id=example2.id order by nameName address salaryiiiihhhh     12369iiiihhhh     12369rrrrtttt	       65894wswsweww   10000
SQL-FULL JOINThe FULL JOIN keyword return rows when there is a match in one of the tables.SELECT column_name(s)FROM table_name1FULL JOIN table_name2ON table_name1.column_name=table_name2.column_name
SQL-FULL JOINselect name,address,salary from example full join example2 on example.id=example2.id order by nameName address salaryhghgyuyu	     NULLiiiihhhh	    12369iiiihhhh	    12369klkliooo       NULLrrrrtttt	    65894wswsweww   10000
SQL-VIEWviews can be considered as virtual tables and it physically stores the data. A view also has a set of definitions,and it does not physically store the data.The syntax for creating a view is as follows: CREATE VIEW "VIEW_NAME" AS "SQL Statement"
SQL-VIEWcreate view vex as select *from exselect *from vexid    name address123	pop	yuyu456	huh	ioioexareredrop view vex
SQL-DISTINCTThe SELECT UNIQUE term is an Oracle-only SQL statement. It is equivalent to SELECT DISTINCT. SyntaX:SELECT DISTINCT "column_name"FROM "table_name“Eg: select *from exId   name address123	pop	yuyu456	huh	ioio856	exaklkk856	exaklkk
SQL-IN & LIKESELECT "column_name“ FROM "table_name"WHERE "column_name" IN ('value1', 'value2', ...)select name,address from ex where id in(456)name addresshuh	ioioSELECT "column_name“ FROM "table_name"WHERE "column_name" LIKE {PATTERN}select name,address from ex where id like(456)name addressHuh ioio
End)Prabhu.ftz@gmail.com

More Related Content

PPTX
DOCX
Bibashsql
PPTX
Lecture 3 sql {basics ddl commands}
PPTX
Lecture 4 sql {basics keys and constraints}
PPTX
Ppt INFORMATIVE PRACTICES for class 11th chapter 14
PPT
Select To Order By
PPT
MY SQL
Bibashsql
Lecture 3 sql {basics ddl commands}
Lecture 4 sql {basics keys and constraints}
Ppt INFORMATIVE PRACTICES for class 11th chapter 14
Select To Order By
MY SQL

What's hot (14)

DOCX
Learning sql from w3schools
PPTX
06.01 sql select distinct
PPT
mysqlHiep.ppt
PPT
SQL querys in detail || Sql query slides
PDF
R for you
PPT
Db1 lecture4
PDF
2013 28-03-dak-why-fp
PDF
Writeable CTEs: The Next Big Thing
PPT
SQL || overview and detailed information about Sql
PPTX
12c Mini Lesson - Invisible Columns
PDF
MySQL partitions tutorial
PPTX
Python data structures
PDF
SQL Functions and Operators
Learning sql from w3schools
06.01 sql select distinct
mysqlHiep.ppt
SQL querys in detail || Sql query slides
R for you
Db1 lecture4
2013 28-03-dak-why-fp
Writeable CTEs: The Next Big Thing
SQL || overview and detailed information about Sql
12c Mini Lesson - Invisible Columns
MySQL partitions tutorial
Python data structures
SQL Functions and Operators
Ad

Viewers also liked (14)

PDF
Database Systems - Introduction to SQL (Chapter 3/1)
PPT
Sql – Structured Query Language
PPTX
RDBMS and SQL
PPTX
Sql basics
PPT
Sql intro & ddl 1
PDF
RDBMS SQL Basics
PPT
MYSQL.ppt
DOC
DBMS Practical File
PPT
SQL Tutorial - Basic Commands
PDF
CBSE XII Database Concepts And MySQL Presentation
PPT
Sql ppt
DOC
A must Sql notes for beginners
PDF
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Database Systems - Introduction to SQL (Chapter 3/1)
Sql – Structured Query Language
RDBMS and SQL
Sql basics
Sql intro & ddl 1
RDBMS SQL Basics
MYSQL.ppt
DBMS Practical File
SQL Tutorial - Basic Commands
CBSE XII Database Concepts And MySQL Presentation
Sql ppt
A must Sql notes for beginners
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Ad

Similar to Sql (20)

PDF
Structured Query Language - All commands Notes
PPTX
Commands
PPTX
Creating database using sql commands
PDF
SQL Quick Reference Card
PPT
Ms sql server ii
PPTX
Sql practise for beginners
PPT
Sql dml & tcl 2
PPTX
Java class 8
PPT
Mysql 120831075600-phpapp01
PPTX
Crime record management system project.pptx
PPTX
Avinash database
PPTX
Aggregate functions in SQL.pptx
PPT
dbs class 7.ppt
PDF
SQL Overview
PPT
SQL : introduction
PPTX
Aggregate functions in SQL.pptx
PPTX
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
PPT
Oracle naveen Sql
PPT
Oracle naveen Sql
PPT
SQL. It education ppt for reference sql process coding
Structured Query Language - All commands Notes
Commands
Creating database using sql commands
SQL Quick Reference Card
Ms sql server ii
Sql practise for beginners
Sql dml & tcl 2
Java class 8
Mysql 120831075600-phpapp01
Crime record management system project.pptx
Avinash database
Aggregate functions in SQL.pptx
dbs class 7.ppt
SQL Overview
SQL : introduction
Aggregate functions in SQL.pptx
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
Oracle naveen Sql
Oracle naveen Sql
SQL. It education ppt for reference sql process coding

Recently uploaded (20)

PPTX
Institutional Correction lecture only . . .
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Pharma ospi slides which help in ospi learning
PDF
Insiders guide to clinical Medicine.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Cell Types and Its function , kingdom of life
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
master seminar digital applications in india
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
Pre independence Education in Inndia.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
Institutional Correction lecture only . . .
O7-L3 Supply Chain Operations - ICLT Program
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Pharma ospi slides which help in ospi learning
Insiders guide to clinical Medicine.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Basic Mud Logging Guide for educational purpose
Cell Types and Its function , kingdom of life
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Supply Chain Operations Speaking Notes -ICLT Program
master seminar digital applications in india
Anesthesia in Laparoscopic Surgery in India
Module 4: Burden of Disease Tutorial Slides S2 2025
Abdominal Access Techniques with Prof. Dr. R K Mishra
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Pre independence Education in Inndia.pdf
Microbial diseases, their pathogenesis and prophylaxis

Sql

  • 2. SQL-Create tableCreate table table_name(column_name1 datatype, column_name2 datatype……)Eg:create table example (id int ,name varchar(10),address varchar(10))Msg:Command(s) completed successfully.
  • 3. SQL-Insert ValuesInsert into table_name(column1,column2,…..)values(values1,values2,…)Eg:insert into example (id,name,address) values(123,'xxxx','yyyyy')Msg:(1 row(s) affected)
  • 4. SQL-Select Commandselect *from exampleId name address123 xxxxyyyyy456 jjjjrrrr456 iiiinnnn567 eeeeffff
  • 5. SQL-Alter CommandAlter table table_name add or drop column_namedatatypeEg: alter table example add mobilenointMsg: Command(s) completed successfully.Id name address mobileno123 xxxxyyyyy NULL456 jjjjrrrr NULL888 iiiinnnn NULL567 eeeeffff NULL
  • 6. SQL-Update CommandUpdate table_name set column_name=new value where column_name=any valueEg: Update example set id=888 where name='iiii‘Msg: (1 row(s) affected)Id name address123 xxxxyyyyy456 jjjjrrrr888 iiiinnnn567 eeeeffff
  • 7. SQL-Delete CommandDelete table_name where conditionEg: delete example where id=888Msg: (1 row(s) affected)Id name address mobileno123 xxxxyyyyy NULL456 jjjjrrrr NULL567 eeeeffff NULL
  • 8. SQL-Drop CommandDrop table table_nameEg: drop table exampleMsg:Command(s) completed successfully.
  • 9. SQL-Primary Key & Foreign Key CREATE TABLE table_name (column1 datatype null/not null, column2 datatype null/not null,...CONSTRAINT constraint_namePRIMARY KEY (column1, column2, . column_n));CREATE TABLE table_name (column1 datatype,  column2 datatype, column3 datatype,  Primary Key (column_any), Foreign Key (Column_any) references Table_any(datatype));
  • 10. SQL-Primary Key & foreign Keycreate table example (id intprimary key,namevarchar(10),address varchar(10))A primary key is used to unique and Not Null identify each row in the table.create table example2 (salary int,expamountint, id int references example(id))A foreign key is a referential constraint between two tables. 
  • 11. SQL-Primary Key & Foreign Key Id name address 123 rrrrtttt369 klkliooo456 iiiihhhh7889 wswswewwSalary expamount id10000 4235 788912369 8526 45612369 865 45665894 12589 123Example (primary Key tale)Example2 (Foreign Key tale)
  • 12. SQL-DISTINCTselect distinct address from exaddressioioklkkyuyu
  • 13. SQL-Primary Key & Foreign Key select name,address,salary from example e,example2 e2 where e.id=e2.idO/PName address salarywswsweww 10000iiiihhhh 12369iiiihhhh 12369rrrrtttt 65894
  • 14. SQL-BETWEEN & COUNTSELECT "column_name“ FROM "table_name"WHERE "column_name" BETWEEN 'value1' AND 'value2‘select id from ex where id between 100 and 500ID123456SELECT COUNT("column_name") FROM "table_name“select count(id)'No Of Records' from exNo Of Records4
  • 15. SQL-Connection Stringstring strcon = "Data Source=172.16.0.1;Initial Catalog=BatchThree;User ID=magnum;Password=Magnum";SqlConnectionsqlcon = new SqlConnection(strcon);sqlcon.Open();stringstrsql = "insert into datab values ('" + txtmarks1.Text + "','" + txtmarks2.Text + "','" + txtmarks3.Text + "','" + txtname.Text + "')";SqlCommandcmd = new SqlCommand(strsql, sqlcon);cmd.CommandType = CommandType.Text;cmd.ExecuteNonQuery();sqlcon.Close();
  • 19. SQL-Stored Procedurecreate procedure proexample(@id int,@namevarchar(10),@address varchar(10)) as insert into example(id,name,address) values (@id,@name,@address)Command(s) completed successfully.exec proexample 666,'hghg','yuyu’(1 row(s) affected)
  • 20. SQL-Stored Procedureselect *from exampleId name address123 rrrrtttt369 klkliooo456 iiiihhhh666 hghgyuyu7889 wswsweww
  • 21. SQL-JOINSSQL joins are used to query data from two or more tables, based on a relationship between certain columns in these tablesInner JoinLeft JoinRight JoinFull Join
  • 22. SQL-INNER JOINThe INNER JOIN keyword return rows when there is at least one match in both tables.SELECT column_name(s)FROM table_name1INNER JOIN table_name2ON table_name1.column_name=table_name2.column_name
  • 23. SQL-INNER JOINselect name,address,salary from example inner join example2 on example.id=example2.id order by nameName address salaryiiiihhhh 12369iiiihhhh 12369rrrrtttt 65894Wswsweww 10000
  • 24. SQL-LEFT JOINThe LEFT JOIN keyword returns all rows from the left table (table_name1), even if there are no matches in the right table (table_name2)SELECT column_name(s)FROM table_name1LEFT JOIN table_name2ON table_name1.column_name=table_name2.column_name
  • 25. SQL_LEFT JOINselect name,address,salary from example left join example2 on example.id=example2.id order by nameName address salaryhghgyuyu NULLiiiihhhh 12369iiiihhhh 12369klkliooo NULLrrrrtttt 65894wswsweww 10000
  • 26. SQL-RIGHT JOINThe RIGHT JOIN keyword returns all the rows from the right table (table_name2), even if there are no matches in the left table (table_name1)SELECT column_name(s)FROM table_name1RIGHT JOIN table_name2ON table_name1.column_name=table_name2.column_name
  • 27. SQL_RIGHT JOINselect name,address,salary from example right join example2 on example.id=example2.id order by nameName address salaryiiiihhhh 12369iiiihhhh 12369rrrrtttt 65894wswsweww 10000
  • 28. SQL-FULL JOINThe FULL JOIN keyword return rows when there is a match in one of the tables.SELECT column_name(s)FROM table_name1FULL JOIN table_name2ON table_name1.column_name=table_name2.column_name
  • 29. SQL-FULL JOINselect name,address,salary from example full join example2 on example.id=example2.id order by nameName address salaryhghgyuyu NULLiiiihhhh 12369iiiihhhh 12369klkliooo NULLrrrrtttt 65894wswsweww 10000
  • 30. SQL-VIEWviews can be considered as virtual tables and it physically stores the data. A view also has a set of definitions,and it does not physically store the data.The syntax for creating a view is as follows: CREATE VIEW "VIEW_NAME" AS "SQL Statement"
  • 31. SQL-VIEWcreate view vex as select *from exselect *from vexid name address123 pop yuyu456 huh ioioexareredrop view vex
  • 32. SQL-DISTINCTThe SELECT UNIQUE term is an Oracle-only SQL statement. It is equivalent to SELECT DISTINCT. SyntaX:SELECT DISTINCT "column_name"FROM "table_name“Eg: select *from exId name address123 pop yuyu456 huh ioio856 exaklkk856 exaklkk
  • 33. SQL-IN & LIKESELECT "column_name“ FROM "table_name"WHERE "column_name" IN ('value1', 'value2', ...)select name,address from ex where id in(456)name addresshuh ioioSELECT "column_name“ FROM "table_name"WHERE "column_name" LIKE {PATTERN}select name,address from ex where id like(456)name addressHuh ioio