SlideShare a Scribd company logo
2
Most read
4
Most read
7
Most read
8SQL SERVER: RETREIVINGDATA FROM A DATABASE
Retrieving Data from DatabaseHow to retrieve data from the given database?After creating the database structure, customizing it to fit the needs and feeding it with data, the next step is to retrieve required data for performing various operations.So how do we get these data?The answer:			Just like in English language, Microsoft SQL Server also provides us the basic keyword for retrieval of data called “Select”SELECT
Select SyntaxThe Syntax of the select statement is simple:The basic syntax for this DML ( Data manipulation Language) command is select <fieldName1, fieldName2,…> from <table name>;This will select the appropriate columns for the given table.  As it is a DML command, it is not necessary to use the keyword TABLE(,as in ‘alter table’)
Displaying the entire tableWhat if it is needed to display all the columns?The Syntax is:select * from tablename;‘*’, the most widely used wildcard comes to our aid. Isn’t it much better than remembering all the column names.Example: select * from student; displays the entire student table
Selecting selective recordsHow to display only certain rows containing the appropriate column?SQL Server answers this question with two simple commands: where
likeselect * from tablename where <conditions>;select * from tablename where fieldNamelike <conditions>;
LIKE explainedSQL Command:Select * from cartoon	where cartoonName like ‘Laughs and Gags’The Where clause: Where is used to specify a condition for the Query
 For string matching, use the ‘like’ keyword. Here, wild card characters(% and _)% -character represents a group(or single) of characters _ -character represents a single characterIllustration:To Update cartoons whose names start with the letter ‘a’ must be given as Update cartoon set rating=100 	where cartoonName = ‘a%’
LIKE explainedIllustration:To Update cartoons whose names start with the letter ‘a’ and the name must of 3 characters in length:Update cartoon set rating=100 	where cartoonName = ‘a__’
Filter-out duplicate selectionsNow, we have a problem. What if there are two records have the same data? The select command will select both the records. To avoid this the distinct keyword is used.select distinct <col> from tablename;Note:	Use distinct only for a single column.
Grouping of recordsIn SQL, it is possible to group records based on the values of a particular field.Syntax:Select * from <tableName> group by <fieldName>;Example: To display the details of students, grouped based on their class, the command will be:Select * from student group by class;
Ordering of recordsIn SQL, it is possible to sort records based on the values of a particular field.Syntax:Select * from <tableName> order by <fieldName>;Example: To display the details of students, sorted based on their GPAs, the command will be:Select * from student order bygpa;The default ordering is ascending in nature. To make it into descending, use the desc keyword. Eg:Select * from student order bygpadesc;

More Related Content

PPT
Dbms relational model
PPTX
Database architecture
PDF
RNA-seq Analysis
PPTX
Genome annotation
PPTX
Genome mapping
PPTX
Relational databases
PPTX
Gene mapping tools
PPTX
Dbms relational model
Database architecture
RNA-seq Analysis
Genome annotation
Genome mapping
Relational databases
Gene mapping tools

What's hot (20)

PDF
Dot matrix
PPT
PPTX
Comparative genomics
PPTX
Data Manipulation Language (DML).pptx
PDF
Tools and database of NCBI
PPTX
Clustal W - Multiple Sequence alignment
PPT
SQL.ppt
PPTX
Sequence and Structural Databases of DNA and Protein, and its significance in...
PPTX
database language ppt.pptx
PPTX
Dot matrix Analysis Tools (Bioinformatics)
PPTX
gene prediction programs
PDF
Phylogenetic analysis
PPT
HMM (Hidden Markov Model)
PPTX
basic structure of SQL FINAL.pptx
PPT
Normalization DBMS.ppt
PPTX
Comparative genomics presentation
PPT
Sql dml & tcl 2
PPT
Genome editing
PPTX
Databases short nucletide polymorphism
Dot matrix
Comparative genomics
Data Manipulation Language (DML).pptx
Tools and database of NCBI
Clustal W - Multiple Sequence alignment
SQL.ppt
Sequence and Structural Databases of DNA and Protein, and its significance in...
database language ppt.pptx
Dot matrix Analysis Tools (Bioinformatics)
gene prediction programs
Phylogenetic analysis
HMM (Hidden Markov Model)
basic structure of SQL FINAL.pptx
Normalization DBMS.ppt
Comparative genomics presentation
Sql dml & tcl 2
Genome editing
Databases short nucletide polymorphism
Ad

Viewers also liked (20)

ODP
Miedo Jajjjajajja
PPT
Wisconsin Fertility Institute: Injection Class 2011
PPTX
SPSS: Quick Look
PDF
Norihicodanch
PPT
HistoriografíA Latina LatíN Ii
PPTX
R Statistics
PPTX
Data Applied: Association
PPTX
Data Applied: Developer Quicklook
PPS
Quantica Construction Search
PDF
Huidige status van de testtaal TTCN-3
PPTX
Communicating simply
PPTX
MS SQL SERVER: Microsoft naive bayes algorithm
PPTX
MySql:Introduction
PPTX
Public Transportation
PPTX
Bernoullis Random Variables And Binomial Distribution
PPT
Épica Latina Latín II
PDF
Vision To Profit V2 Sept 2009
PPTX
Info Chimps: What Makes Infochimps.org Unique
PPT
Survival Strategies For Testers
Miedo Jajjjajajja
Wisconsin Fertility Institute: Injection Class 2011
SPSS: Quick Look
Norihicodanch
HistoriografíA Latina LatíN Ii
R Statistics
Data Applied: Association
Data Applied: Developer Quicklook
Quantica Construction Search
Huidige status van de testtaal TTCN-3
Communicating simply
MS SQL SERVER: Microsoft naive bayes algorithm
MySql:Introduction
Public Transportation
Bernoullis Random Variables And Binomial Distribution
Épica Latina Latín II
Vision To Profit V2 Sept 2009
Info Chimps: What Makes Infochimps.org Unique
Survival Strategies For Testers
Ad

Similar to Retrieving Data From A Database (20)

PPTX
Introduction to SQl Commands.pptxhhjhvvb
DOCX
Assg2 b 19121033-converted
PPTX
lect 2.pptx
PPTX
SQl data base management and design
PDF
Sql smart reference_by_prasad
PDF
Sql smart reference_by_prasad
PPTX
Fundamentals of Database management system Lab Manual.pptx
PDF
Sql select statement
PPTX
Its about a sql topic for basic structured query language
PPTX
SQL commands in database managemant systems
PPTX
Lab1 select statement
PPTX
SQL commands
PPTX
Intro to T-SQL – 2nd session
PPTX
SQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12 CBSE
DOC
Oracle notes
PPTX
Database COMPLETE
PPTX
SQL OVERVIEW for a new introduced student.pptx
PPTX
Beginers guide for oracle sql
PDF
Structure query language, database course
PDF
Basic sqlstatements
Introduction to SQl Commands.pptxhhjhvvb
Assg2 b 19121033-converted
lect 2.pptx
SQl data base management and design
Sql smart reference_by_prasad
Sql smart reference_by_prasad
Fundamentals of Database management system Lab Manual.pptx
Sql select statement
Its about a sql topic for basic structured query language
SQL commands in database managemant systems
Lab1 select statement
SQL commands
Intro to T-SQL – 2nd session
SQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12 CBSE
Oracle notes
Database COMPLETE
SQL OVERVIEW for a new introduced student.pptx
Beginers guide for oracle sql
Structure query language, database course
Basic sqlstatements

More from DataminingTools Inc (20)

PPTX
Terminology Machine Learning
PPTX
Techniques Machine Learning
PPTX
Machine learning Introduction
PPTX
Areas of machine leanring
PPTX
AI: Planning and AI
PPTX
AI: Logic in AI 2
PPTX
AI: Logic in AI
PPTX
AI: Learning in AI 2
PPTX
AI: Learning in AI
PPTX
AI: Introduction to artificial intelligence
PPTX
AI: Belief Networks
PPTX
AI: AI & Searching
PPTX
AI: AI & Problem Solving
PPTX
Data Mining: Text and web mining
PPTX
Data Mining: Outlier analysis
PPTX
Data Mining: Mining stream time series and sequence data
PPTX
Data Mining: Mining ,associations, and correlations
PPTX
Data Mining: Graph mining and social network analysis
PPTX
Data warehouse and olap technology
PPTX
Data Mining: Data processing
Terminology Machine Learning
Techniques Machine Learning
Machine learning Introduction
Areas of machine leanring
AI: Planning and AI
AI: Logic in AI 2
AI: Logic in AI
AI: Learning in AI 2
AI: Learning in AI
AI: Introduction to artificial intelligence
AI: Belief Networks
AI: AI & Searching
AI: AI & Problem Solving
Data Mining: Text and web mining
Data Mining: Outlier analysis
Data Mining: Mining stream time series and sequence data
Data Mining: Mining ,associations, and correlations
Data Mining: Graph mining and social network analysis
Data warehouse and olap technology
Data Mining: Data processing

Recently uploaded (20)

PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
Cloud computing and distributed systems.
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
Agricultural_Statistics_at_a_Glance_2022_0.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Building Integrated photovoltaic BIPV_UPV.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Encapsulation theory and applications.pdf
Cloud computing and distributed systems.
Unlocking AI with Model Context Protocol (MCP)
Dropbox Q2 2025 Financial Results & Investor Presentation
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
“AI and Expert System Decision Support & Business Intelligence Systems”
NewMind AI Weekly Chronicles - August'25 Week I
Chapter 3 Spatial Domain Image Processing.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing

Retrieving Data From A Database

  • 2. Retrieving Data from DatabaseHow to retrieve data from the given database?After creating the database structure, customizing it to fit the needs and feeding it with data, the next step is to retrieve required data for performing various operations.So how do we get these data?The answer: Just like in English language, Microsoft SQL Server also provides us the basic keyword for retrieval of data called “Select”SELECT
  • 3. Select SyntaxThe Syntax of the select statement is simple:The basic syntax for this DML ( Data manipulation Language) command is select <fieldName1, fieldName2,…> from <table name>;This will select the appropriate columns for the given table. As it is a DML command, it is not necessary to use the keyword TABLE(,as in ‘alter table’)
  • 4. Displaying the entire tableWhat if it is needed to display all the columns?The Syntax is:select * from tablename;‘*’, the most widely used wildcard comes to our aid. Isn’t it much better than remembering all the column names.Example: select * from student; displays the entire student table
  • 5. Selecting selective recordsHow to display only certain rows containing the appropriate column?SQL Server answers this question with two simple commands: where
  • 6. likeselect * from tablename where <conditions>;select * from tablename where fieldNamelike <conditions>;
  • 7. LIKE explainedSQL Command:Select * from cartoon where cartoonName like ‘Laughs and Gags’The Where clause: Where is used to specify a condition for the Query
  • 8. For string matching, use the ‘like’ keyword. Here, wild card characters(% and _)% -character represents a group(or single) of characters _ -character represents a single characterIllustration:To Update cartoons whose names start with the letter ‘a’ must be given as Update cartoon set rating=100 where cartoonName = ‘a%’
  • 9. LIKE explainedIllustration:To Update cartoons whose names start with the letter ‘a’ and the name must of 3 characters in length:Update cartoon set rating=100 where cartoonName = ‘a__’
  • 10. Filter-out duplicate selectionsNow, we have a problem. What if there are two records have the same data? The select command will select both the records. To avoid this the distinct keyword is used.select distinct <col> from tablename;Note: Use distinct only for a single column.
  • 11. Grouping of recordsIn SQL, it is possible to group records based on the values of a particular field.Syntax:Select * from <tableName> group by <fieldName>;Example: To display the details of students, grouped based on their class, the command will be:Select * from student group by class;
  • 12. Ordering of recordsIn SQL, it is possible to sort records based on the values of a particular field.Syntax:Select * from <tableName> order by <fieldName>;Example: To display the details of students, sorted based on their GPAs, the command will be:Select * from student order bygpa;The default ordering is ascending in nature. To make it into descending, use the desc keyword. Eg:Select * from student order bygpadesc;
  • 13. Summary8. Retrieving data from a database: Select Syntax
  • 18. Order byVisit more self help tutorialsPick a tutorial of your choice and browse through it at your own pace.The tutorials section is free, self-guiding and will not involve any additional support.Visit us at www.dataminingtools.net