SlideShare une entreprise Scribd logo
1  sur  12
8 SQL SERVER: RETREIVINGDATA FROM A DATABASE
Retrieving Data from Database How 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 Syntax The 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 table What 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 records How to display only certain rows containing the appropriate column? SQL Server answers this question with two simple commands:  ,[object Object]
likeselect * from tablename where <conditions>; select * from tablename where fieldNamelike <conditions>;
LIKE explained SQL Command: Select * from cartoon 	where cartoonName like ‘Laughs and Gags’ The Where clause: ,[object Object]
 For string matching, use the ‘like’ keyword. Here, wild card characters(% and _)% -character represents a group(or single) of characters  _ -character represents a single character Illustration: To Update cartoons whose names start with the letter ‘a’ must be given as  Update cartoon set rating=100  	where cartoonName = ‘a%’
LIKE explained Illustration: 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 selections Now, 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 records In 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 records In 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;

Contenu connexe

Tendances

Data Manipulation Language
Data Manipulation LanguageData Manipulation Language
Data Manipulation LanguageJas Singh Bhasin
 
SQL-Alter Table, SELECT DISTINCT & WHERE
SQL-Alter Table, SELECT DISTINCT & WHERESQL-Alter Table, SELECT DISTINCT & WHERE
SQL-Alter Table, SELECT DISTINCT & WHEREI L0V3 CODING DR
 
SQL: Structured Query Language
SQL: Structured Query LanguageSQL: Structured Query Language
SQL: Structured Query LanguageRohit Bisht
 
Data Manipulation(DML) and Transaction Control (TCL)
Data Manipulation(DML) and Transaction Control (TCL)  Data Manipulation(DML) and Transaction Control (TCL)
Data Manipulation(DML) and Transaction Control (TCL) MuhammadWaheed44
 
Intro to t sql – 3rd session
Intro to t sql – 3rd sessionIntro to t sql – 3rd session
Intro to t sql – 3rd sessionMedhat Dawoud
 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESVENNILAV6
 
SQL Readable Outputs - Oracle SQL Fundamentals
SQL Readable Outputs - Oracle SQL FundamentalsSQL Readable Outputs - Oracle SQL Fundamentals
SQL Readable Outputs - Oracle SQL FundamentalsMuhammadWaheed44
 
Oracle SQL Fundamentals - Lecture 3
Oracle SQL Fundamentals - Lecture 3Oracle SQL Fundamentals - Lecture 3
Oracle SQL Fundamentals - Lecture 3MuhammadWaheed44
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteAl-Mamun Sarkar
 
Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statementsMohd Tousif
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasadpaddu123
 
Sql delete, truncate, drop statements
Sql delete, truncate, drop statementsSql delete, truncate, drop statements
Sql delete, truncate, drop statementsVivek Singh
 

Tendances (17)

Data Manipulation Language
Data Manipulation LanguageData Manipulation Language
Data Manipulation Language
 
SQL-Alter Table, SELECT DISTINCT & WHERE
SQL-Alter Table, SELECT DISTINCT & WHERESQL-Alter Table, SELECT DISTINCT & WHERE
SQL-Alter Table, SELECT DISTINCT & WHERE
 
SQL: Structured Query Language
SQL: Structured Query LanguageSQL: Structured Query Language
SQL: Structured Query Language
 
Data Manipulation(DML) and Transaction Control (TCL)
Data Manipulation(DML) and Transaction Control (TCL)  Data Manipulation(DML) and Transaction Control (TCL)
Data Manipulation(DML) and Transaction Control (TCL)
 
Intro to t sql – 3rd session
Intro to t sql – 3rd sessionIntro to t sql – 3rd session
Intro to t sql – 3rd session
 
Oracle: DML
Oracle: DMLOracle: DML
Oracle: DML
 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIES
 
Chapter8 my sql revision tour
Chapter8 my sql revision tourChapter8 my sql revision tour
Chapter8 my sql revision tour
 
SQL Readable Outputs - Oracle SQL Fundamentals
SQL Readable Outputs - Oracle SQL FundamentalsSQL Readable Outputs - Oracle SQL Fundamentals
SQL Readable Outputs - Oracle SQL Fundamentals
 
Oracle SQL Fundamentals - Lecture 3
Oracle SQL Fundamentals - Lecture 3Oracle SQL Fundamentals - Lecture 3
Oracle SQL Fundamentals - Lecture 3
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and delete
 
Sql commands
Sql commandsSql commands
Sql commands
 
intro for sql
intro for sql intro for sql
intro for sql
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statements
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
Sql delete, truncate, drop statements
Sql delete, truncate, drop statementsSql delete, truncate, drop statements
Sql delete, truncate, drop statements
 

En vedette

MS SQL SERVER: Using the data mining tools
MS SQL SERVER: Using the data mining toolsMS SQL SERVER: Using the data mining tools
MS SQL SERVER: Using the data mining toolssqlserver content
 
MS Sql Server: Reporting introduction
MS Sql Server: Reporting introductionMS Sql Server: Reporting introduction
MS Sql Server: Reporting introductionsqlserver content
 
MS Sql Server: Business Intelligence
MS Sql Server: Business IntelligenceMS Sql Server: Business Intelligence
MS Sql Server: Business Intelligencesqlserver content
 
MS Sql Server: Datamining Introduction
MS Sql Server: Datamining IntroductionMS Sql Server: Datamining Introduction
MS Sql Server: Datamining Introductionsqlserver content
 
MS SQL SERVER: Microsoft sequence clustering and association rules
MS SQL SERVER: Microsoft sequence clustering and association rulesMS SQL SERVER: Microsoft sequence clustering and association rules
MS SQL SERVER: Microsoft sequence clustering and association rulessqlserver content
 
MS SQLSERVER:Feeding Data Into Database
MS SQLSERVER:Feeding Data Into DatabaseMS SQLSERVER:Feeding Data Into Database
MS SQLSERVER:Feeding Data Into Databasesqlserver content
 
MS SQL SERVER: Neural network and logistic regression
MS SQL SERVER: Neural network and logistic regressionMS SQL SERVER: Neural network and logistic regression
MS SQL SERVER: Neural network and logistic regressionsqlserver content
 
MS Sql Server: Reporting basics
MS Sql  Server: Reporting basicsMS Sql  Server: Reporting basics
MS Sql Server: Reporting basicssqlserver content
 
MS SQL SERVER: Creating A Database
MS SQL SERVER: Creating A DatabaseMS SQL SERVER: Creating A Database
MS SQL SERVER: Creating A Databasesqlserver content
 
MS SQLSERVER:Doing Calculations With Functions
MS SQLSERVER:Doing Calculations With FunctionsMS SQLSERVER:Doing Calculations With Functions
MS SQLSERVER:Doing Calculations With Functionssqlserver content
 
MS SQL SERVER: Introduction To Database Concepts
MS SQL SERVER: Introduction To Database ConceptsMS SQL SERVER: Introduction To Database Concepts
MS SQL SERVER: Introduction To Database Conceptssqlserver content
 
MS SQLSERVER:Manipulating Database
MS SQLSERVER:Manipulating DatabaseMS SQLSERVER:Manipulating Database
MS SQLSERVER:Manipulating Databasesqlserver content
 
MS SQL SERVER: SSIS and data mining
MS SQL SERVER: SSIS and data miningMS SQL SERVER: SSIS and data mining
MS SQL SERVER: SSIS and data miningsqlserver content
 
MS SQLSERVER:Joining Databases
MS SQLSERVER:Joining DatabasesMS SQLSERVER:Joining Databases
MS SQLSERVER:Joining Databasessqlserver content
 
MS SQL SERVER: Getting Started With Sql Server 2008
MS SQL SERVER: Getting Started With Sql Server 2008MS SQL SERVER: Getting Started With Sql Server 2008
MS SQL SERVER: Getting Started With Sql Server 2008sqlserver content
 

En vedette (15)

MS SQL SERVER: Using the data mining tools
MS SQL SERVER: Using the data mining toolsMS SQL SERVER: Using the data mining tools
MS SQL SERVER: Using the data mining tools
 
MS Sql Server: Reporting introduction
MS Sql Server: Reporting introductionMS Sql Server: Reporting introduction
MS Sql Server: Reporting introduction
 
MS Sql Server: Business Intelligence
MS Sql Server: Business IntelligenceMS Sql Server: Business Intelligence
MS Sql Server: Business Intelligence
 
MS Sql Server: Datamining Introduction
MS Sql Server: Datamining IntroductionMS Sql Server: Datamining Introduction
MS Sql Server: Datamining Introduction
 
MS SQL SERVER: Microsoft sequence clustering and association rules
MS SQL SERVER: Microsoft sequence clustering and association rulesMS SQL SERVER: Microsoft sequence clustering and association rules
MS SQL SERVER: Microsoft sequence clustering and association rules
 
MS SQLSERVER:Feeding Data Into Database
MS SQLSERVER:Feeding Data Into DatabaseMS SQLSERVER:Feeding Data Into Database
MS SQLSERVER:Feeding Data Into Database
 
MS SQL SERVER: Neural network and logistic regression
MS SQL SERVER: Neural network and logistic regressionMS SQL SERVER: Neural network and logistic regression
MS SQL SERVER: Neural network and logistic regression
 
MS Sql Server: Reporting basics
MS Sql  Server: Reporting basicsMS Sql  Server: Reporting basics
MS Sql Server: Reporting basics
 
MS SQL SERVER: Creating A Database
MS SQL SERVER: Creating A DatabaseMS SQL SERVER: Creating A Database
MS SQL SERVER: Creating A Database
 
MS SQLSERVER:Doing Calculations With Functions
MS SQLSERVER:Doing Calculations With FunctionsMS SQLSERVER:Doing Calculations With Functions
MS SQLSERVER:Doing Calculations With Functions
 
MS SQL SERVER: Introduction To Database Concepts
MS SQL SERVER: Introduction To Database ConceptsMS SQL SERVER: Introduction To Database Concepts
MS SQL SERVER: Introduction To Database Concepts
 
MS SQLSERVER:Manipulating Database
MS SQLSERVER:Manipulating DatabaseMS SQLSERVER:Manipulating Database
MS SQLSERVER:Manipulating Database
 
MS SQL SERVER: SSIS and data mining
MS SQL SERVER: SSIS and data miningMS SQL SERVER: SSIS and data mining
MS SQL SERVER: SSIS and data mining
 
MS SQLSERVER:Joining Databases
MS SQLSERVER:Joining DatabasesMS SQLSERVER:Joining Databases
MS SQLSERVER:Joining Databases
 
MS SQL SERVER: Getting Started With Sql Server 2008
MS SQL SERVER: Getting Started With Sql Server 2008MS SQL SERVER: Getting Started With Sql Server 2008
MS SQL SERVER: Getting Started With Sql Server 2008
 

Similaire à SQL SERVER: WAYS TO RETRIEVE DATA

Assg2 b 19121033-converted
Assg2 b 19121033-convertedAssg2 b 19121033-converted
Assg2 b 19121033-convertedSUSHANTPHALKE2
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasadpaddu123
 
Sql select statement
Sql select statementSql select statement
Sql select statementVivek Singh
 
Its about a sql topic for basic structured query language
Its about a sql topic for basic structured query languageIts about a sql topic for basic structured query language
Its about a sql topic for basic structured query languageIMsKanchanaI
 
Intro to T-SQL – 2nd session
Intro to T-SQL – 2nd sessionIntro to T-SQL – 2nd session
Intro to T-SQL – 2nd sessionMedhat Dawoud
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETEAbrar ali
 
Beginers guide for oracle sql
Beginers guide for oracle sqlBeginers guide for oracle sql
Beginers guide for oracle sqlN.Jagadish Kumar
 
Basic sqlstatements
Basic sqlstatementsBasic sqlstatements
Basic sqlstatementsAnjac
 
Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)Achmad Solichin
 
Structured Query Language (SQL).pptx
Structured Query Language (SQL).pptxStructured Query Language (SQL).pptx
Structured Query Language (SQL).pptxEllenGracePorras
 

Similaire à SQL SERVER: WAYS TO RETRIEVE DATA (20)

Assg2 b 19121033-converted
Assg2 b 19121033-convertedAssg2 b 19121033-converted
Assg2 b 19121033-converted
 
lect 2.pptx
lect 2.pptxlect 2.pptx
lect 2.pptx
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
Sql select statement
Sql select statementSql select statement
Sql select statement
 
Its about a sql topic for basic structured query language
Its about a sql topic for basic structured query languageIts about a sql topic for basic structured query language
Its about a sql topic for basic structured query language
 
Lab1 select statement
Lab1 select statementLab1 select statement
Lab1 select statement
 
SQL commands
SQL commandsSQL commands
SQL commands
 
Intro to T-SQL – 2nd session
Intro to T-SQL – 2nd sessionIntro to T-SQL – 2nd session
Intro to T-SQL – 2nd session
 
Oracle notes
Oracle notesOracle notes
Oracle notes
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
 
Beginers guide for oracle sql
Beginers guide for oracle sqlBeginers guide for oracle sql
Beginers guide for oracle sql
 
Basic sqlstatements
Basic sqlstatementsBasic sqlstatements
Basic sqlstatements
 
ADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASADADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASAD
 
SQL PPT.pptx
SQL PPT.pptxSQL PPT.pptx
SQL PPT.pptx
 
Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)
 
Les01
Les01Les01
Les01
 
unit-5 sql notes.docx
unit-5 sql notes.docxunit-5 sql notes.docx
unit-5 sql notes.docx
 
DBMS LAB M.docx
DBMS LAB M.docxDBMS LAB M.docx
DBMS LAB M.docx
 
Structured Query Language (SQL).pptx
Structured Query Language (SQL).pptxStructured Query Language (SQL).pptx
Structured Query Language (SQL).pptx
 
012. SQL.pdf
012. SQL.pdf012. SQL.pdf
012. SQL.pdf
 

Plus de sqlserver content

MS SQL SERVER: Programming sql server data mining
MS SQL SERVER:  Programming sql server data miningMS SQL SERVER:  Programming sql server data mining
MS SQL SERVER: Programming sql server data miningsqlserver content
 
MS SQL SERVER: Olap cubes and data mining
MS SQL SERVER:  Olap cubes and data miningMS SQL SERVER:  Olap cubes and data mining
MS SQL SERVER: Olap cubes and data miningsqlserver content
 
MS SQL SERVER: Microsoft time series algorithm
MS SQL SERVER: Microsoft time series algorithmMS SQL SERVER: Microsoft time series algorithm
MS SQL SERVER: Microsoft time series algorithmsqlserver content
 
MS SQL SERVER: Microsoft naive bayes algorithm
MS SQL SERVER: Microsoft naive bayes algorithmMS SQL SERVER: Microsoft naive bayes algorithm
MS SQL SERVER: Microsoft naive bayes algorithmsqlserver content
 
MS SQL SERVER: Decision trees algorithm
MS SQL SERVER: Decision trees algorithmMS SQL SERVER: Decision trees algorithm
MS SQL SERVER: Decision trees algorithmsqlserver content
 
MS SQL Server: Data mining concepts and dmx
MS SQL Server: Data mining concepts and dmxMS SQL Server: Data mining concepts and dmx
MS SQL Server: Data mining concepts and dmxsqlserver content
 
MS Sql Server: Reporting models
MS Sql Server: Reporting modelsMS Sql Server: Reporting models
MS Sql Server: Reporting modelssqlserver content
 
MS Sql Server: Reporting manipulating data
MS Sql Server: Reporting manipulating dataMS Sql Server: Reporting manipulating data
MS Sql Server: Reporting manipulating datasqlserver content
 
MS SQLSERVER:Deleting A Database
MS SQLSERVER:Deleting A DatabaseMS SQLSERVER:Deleting A Database
MS SQLSERVER:Deleting A Databasesqlserver content
 
MS SQLSERVER:Customizing Your D Base Design
MS SQLSERVER:Customizing Your D Base DesignMS SQLSERVER:Customizing Your D Base Design
MS SQLSERVER:Customizing Your D Base Designsqlserver content
 
MS SQLSERVER:Creating A Database
MS SQLSERVER:Creating A DatabaseMS SQLSERVER:Creating A Database
MS SQLSERVER:Creating A Databasesqlserver content
 
MS SQLSERVER:Advanced Query Concepts Copy
MS SQLSERVER:Advanced Query Concepts   CopyMS SQLSERVER:Advanced Query Concepts   Copy
MS SQLSERVER:Advanced Query Concepts Copysqlserver content
 
MS SQLSERVER:Sql Functions And Procedures
MS SQLSERVER:Sql Functions And ProceduresMS SQLSERVER:Sql Functions And Procedures
MS SQLSERVER:Sql Functions And Proceduressqlserver content
 
MS SQL SERVER: Sql Functions And Procedures
MS SQL SERVER: Sql Functions And ProceduresMS SQL SERVER: Sql Functions And Procedures
MS SQL SERVER: Sql Functions And Proceduressqlserver content
 
MS SQL SERVER: Retrieving Data From A Database
MS SQL SERVER: Retrieving Data From A DatabaseMS SQL SERVER: Retrieving Data From A Database
MS SQL SERVER: Retrieving Data From A Databasesqlserver content
 
MS SQL SERVER: Manipulating Database
MS SQL SERVER: Manipulating DatabaseMS SQL SERVER: Manipulating Database
MS SQL SERVER: Manipulating Databasesqlserver content
 
MS SQL SERVER: Joining Databases
MS SQL SERVER: Joining DatabasesMS SQL SERVER: Joining Databases
MS SQL SERVER: Joining Databasessqlserver content
 

Plus de sqlserver content (18)

MS SQL SERVER: Programming sql server data mining
MS SQL SERVER:  Programming sql server data miningMS SQL SERVER:  Programming sql server data mining
MS SQL SERVER: Programming sql server data mining
 
MS SQL SERVER: Olap cubes and data mining
MS SQL SERVER:  Olap cubes and data miningMS SQL SERVER:  Olap cubes and data mining
MS SQL SERVER: Olap cubes and data mining
 
MS SQL SERVER: Microsoft time series algorithm
MS SQL SERVER: Microsoft time series algorithmMS SQL SERVER: Microsoft time series algorithm
MS SQL SERVER: Microsoft time series algorithm
 
MS SQL SERVER: Microsoft naive bayes algorithm
MS SQL SERVER: Microsoft naive bayes algorithmMS SQL SERVER: Microsoft naive bayes algorithm
MS SQL SERVER: Microsoft naive bayes algorithm
 
MS SQL SERVER: Decision trees algorithm
MS SQL SERVER: Decision trees algorithmMS SQL SERVER: Decision trees algorithm
MS SQL SERVER: Decision trees algorithm
 
MS SQL Server: Data mining concepts and dmx
MS SQL Server: Data mining concepts and dmxMS SQL Server: Data mining concepts and dmx
MS SQL Server: Data mining concepts and dmx
 
MS Sql Server: Reporting models
MS Sql Server: Reporting modelsMS Sql Server: Reporting models
MS Sql Server: Reporting models
 
MS Sql Server: Reporting manipulating data
MS Sql Server: Reporting manipulating dataMS Sql Server: Reporting manipulating data
MS Sql Server: Reporting manipulating data
 
MS SQLSERVER:Deleting A Database
MS SQLSERVER:Deleting A DatabaseMS SQLSERVER:Deleting A Database
MS SQLSERVER:Deleting A Database
 
MS SQLSERVER:Customizing Your D Base Design
MS SQLSERVER:Customizing Your D Base DesignMS SQLSERVER:Customizing Your D Base Design
MS SQLSERVER:Customizing Your D Base Design
 
MS SQLSERVER:Creating Views
MS SQLSERVER:Creating ViewsMS SQLSERVER:Creating Views
MS SQLSERVER:Creating Views
 
MS SQLSERVER:Creating A Database
MS SQLSERVER:Creating A DatabaseMS SQLSERVER:Creating A Database
MS SQLSERVER:Creating A Database
 
MS SQLSERVER:Advanced Query Concepts Copy
MS SQLSERVER:Advanced Query Concepts   CopyMS SQLSERVER:Advanced Query Concepts   Copy
MS SQLSERVER:Advanced Query Concepts Copy
 
MS SQLSERVER:Sql Functions And Procedures
MS SQLSERVER:Sql Functions And ProceduresMS SQLSERVER:Sql Functions And Procedures
MS SQLSERVER:Sql Functions And Procedures
 
MS SQL SERVER: Sql Functions And Procedures
MS SQL SERVER: Sql Functions And ProceduresMS SQL SERVER: Sql Functions And Procedures
MS SQL SERVER: Sql Functions And Procedures
 
MS SQL SERVER: Retrieving Data From A Database
MS SQL SERVER: Retrieving Data From A DatabaseMS SQL SERVER: Retrieving Data From A Database
MS SQL SERVER: Retrieving Data From A Database
 
MS SQL SERVER: Manipulating Database
MS SQL SERVER: Manipulating DatabaseMS SQL SERVER: Manipulating Database
MS SQL SERVER: Manipulating Database
 
MS SQL SERVER: Joining Databases
MS SQL SERVER: Joining DatabasesMS SQL SERVER: Joining Databases
MS SQL SERVER: Joining Databases
 

Dernier

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 

Dernier (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 

SQL SERVER: WAYS TO RETRIEVE DATA

  • 1. 8 SQL SERVER: RETREIVINGDATA FROM A DATABASE
  • 2. Retrieving Data from Database How 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 Syntax The 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 table What 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.
  • 6. likeselect * from tablename where <conditions>; select * from tablename where fieldNamelike <conditions>;
  • 7.
  • 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 character Illustration: To Update cartoons whose names start with the letter ‘a’ must be given as Update cartoon set rating=100 where cartoonName = ‘a%’
  • 9. LIKE explained Illustration: 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 selections Now, 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 records In 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 records In 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.
  • 18.