NTAUG Introduction in to use of SQL - Part 2 Peter Dominey Copyright © Peter Dominey 2004, Copyright © Peter Dominey 2004,

Slides:



Advertisements
Similar presentations
NTAUG Introduction in to use of SQL - Part 3 Peter Dominey Copyright © Peter Dominey 2004, Copyright © Peter Dominey 2004,
Advertisements

NTAUG Introduction in to use of SQL Peter Dominey Copyright © Peter Dominey 2004, Copyright © Peter Dominey 2004,
Chapter 4 Joining Multiple Tables
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
With Microsoft Access 2010© 2011 Pearson Education, Inc. Publishing as Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Access.
Introduction To SQL Lynnwood Brown President System Managers LLC Copyright System Managers LLC 2003 all rights reserved.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Session 4 SQL Structured Query Language. SQL Modes of use –Interactive –Embedded Purpose –Create database –Create, Read, Update, Delete.
Introduction to Structured Query Language (SQL)
Introduction to Oracle9i: SQL1 Basic SQL SELECT Statements.
SQL Basics Based on the relational algebra we just learned. Nonprocedural language – what to be done not how Simple, powerful language Used for both data.
Structured Query Language Part I Chapter Three CIS 218.
1 Sample SQL Applications Asst. Prof. Emin Korkut.
WRITING BASIC SQL SELECT STATEMENTS Lecture 7 1. Outlines  SQL SELECT statement  Capabilities of SELECT statements  Basic SELECT statement  Selecting.
+ Structured Query Language Part 2 KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall.
State of Connecticut Core-CT Project Query 4 hrs Updated 1/21/2011.
Ceng 356-Lab1. Objectives After completing this lesson, you should be able to do the following: Get Familiar with the development environment List the.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
Chapter 2 Basic SQL SELECT Statements
Introduction to SQL Yong Choi School of Business CSU, Bakersfield.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
Chapter 2 Basic SQL SELECT Statements Oracle 10g: SQL.
1 Copyright © 2006, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
Copyright  Oracle Corporation, All rights reserved. 1 Writing Basic SQL Statements.
Chapter 9 Joining Data from Multiple Tables
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
SQL – Part I Yong Choi School of Business CSU, Bakersfield.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 11-1 David M. Kroenke’s Chapter Eleven: Managing Databases with SQL Server.
Structure Query Language SQL. Database Terminology Employee ID 3 3 Last name Small First name Tony 5 5 Smith James
2 Writing Basic SELECT Statements. 1-2 Copyright  Oracle Corporation, All rights reserved. Capabilities of SQL SELECT Statements Selection Projection.
Chapter 4Introduction to Oracle9i: SQL1 Chapter 4 Joining Multiple Tables.
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
Intro to SQL Management Studio. Please Be Sure!! Make sure that your access is read only. If it isn’t, you have the potential to change data within your.
Introduction to SQL PART Ⅰ 第一讲 Writing Basic SQL SELECT Statements.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Copyright © 2004, Oracle. All rights reserved. Lecture 4: 1-Retrieving Data Using the SQL SELECT Statement 2-Restricting and Sorting Data Lecture 4: 1-Retrieving.
Queries SELECT [DISTINCT] FROM ( { }| ),... [WHERE ] [GROUP BY [HAVING ]] [ORDER BY [ ],...]
Indexes and Views Unit 7.
Chapter 13 Views Oracle 10g: SQL. Oracle 10g: SQL2 Objectives Create a view, using CREATE VIEW command or the CREATE OR REPLACE VIEW command Employ the.
Session 9 Accessing Data from a Database. RDBMS and Data Management/ Session 9/2 of 34 Session Objectives Describe the SELECT statement, its syntax and.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
Subqueries.
+ Structured Query Language Part 2 KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall.
به نام خدا SQL QUIZ جوانمرد Website: ejavanmard.blogfa.com.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
5 Copyright © 2008, Oracle. All rights reserved. Testing and Validating a Repository.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
 CONACT UC:  Magnific training   
1 Copyright © 2007, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
Chapter 9 Working with Databases. Copyright © 2011 Pearson Addison-Wesley Binding to ListBox and ComboBox Controls List and combo boxes are frequently.
1 Copyright © 2009, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
1 Copyright © 2004, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
IFS180 Intro. to Data Management Chapter 10 - Unions.
Retrieving Data Using the SQL SELECT Statement
MySQL Subquery Source: Dev.MySql.com
Connect to SQL Server and run select statements
Writing Basic SQL SELECT Statements
Basic select statement
Basic Data Manipulation - Reading Data
Database Management  .
PROC SQL, Overview.
Chapter 4 Summary Query.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
Introduction To Structured Query Language (SQL)
Access/SQL Server Eliminate Duplicates with SELECT DISTINCT
Introduction To Structured Query Language (SQL)
Lab 2: Retrieving Data from the Database
Presentation transcript:

NTAUG Introduction in to use of SQL - Part 2 Peter Dominey Copyright © Peter Dominey 2004, Copyright © Peter Dominey 2004,

SQL Review Review

SQL SQL Some Basic SQL Rules Multiple SQL statements are separated by semicolons (;) SQL statement keywords are not case sensitive SQL statement data values are case sensitive All extra white spaces within a SQL statement are ignored. You can add spaces and carriage returns for readability. SQL statements are made up of clauses (e.g., SELECT clause, FROM clause, WHERE clause, etc.)

Common Conventions Used This is the commonly used notation styles and conventions: SELECT [DISTINCT] {* | column-list} FROM table-name Uppercase words = keywords Lowercase words = user supplied data value { } = required items [ ] = optional items | = various choices … = repeating set

SELECT Statement A full SELECT statement consists of 6 clauses: SELECT FROM WHERE GROUP BY HAVING ORDER BY A regular query consists of: SELECT FROM WHERE ORDER BY A grouping (summary) query consists of: SELECT FROM GROUP BY HAVING ORDER BY

Syntactical Diagram of the SELECT Statement ORDER BY ALL * HAVING GROUP BY SELECT FROM WHERE SEARCH CONDITION DISTINCT SELECT-LIST SPECIFY COLUMNS SEARCH CONDITIONS SPECIFY GROUP SORT SPECIFY COLUMN SORT Not all clauses must be used in a query. The minimum that you need for a SELECT statement is SELECT and FROM.

SQL WHERE clause We touched earlier on the where clause We touched earlier on the where clause SELECT job_name FROM job WHERE machine=somename SELECT job_name FROM job WHERE machine=somename And made the use of the simplest form and equals = There are other operators: =Equal <>Not equal >Greater than <Less than >=Greater than or equal <=Less than or equal BETWEEN Between an inclusive range LIKESearch for a pattern

SQL WHERE clause To extract information where you have a list of items: To extract information where you have a list of items: SELECT job_name FROM job WHERE machine IN (machine1,machinezxt,machine1b) SELECT job_name FROM job WHERE machine IN (machine1,machinezxt,machine1b)

SQL Select within Select SELECT job_name FROM job WHERE machine IN (SELECT hostname FROM keymaster) SELECT job_name FROM job WHERE machine IN (SELECT hostname FROM keymaster)

SQL Information from multiple tables Examine the following statement: Examine the following statement: SELECT keymaster.hostid, job.job_name FROM keymaster, job WHERE job.machine=keymaster.hostname SELECT keymaster.hostid, job.job_name FROM keymaster, job WHERE job.machine=keymaster.hostname

Constructing more WHEREs using NOT

Select WHERE & ORDER xql>>[AUTOSYS_SQL_DEV1][autosys] 1> select job_name,owner from job where job_name like 'test%' order by joid ; xql>>[AUTOSYS_SQL_DEV1][autosys] 1> select job_name,owner from job where job_name like 'test%' order by joid ; job_nameowner test_bdsaptc1 autosys test_bdsdbc1 autosys test_bdsaptc1 autosys test_bdsdbc1 autosys

SQL Introduction As stated earlier, this was introduction to SQL and hopefully has provided a taste of the things that can be done to extract information directly from the AutoSys database. As stated earlier, this was introduction to SQL and hopefully has provided a taste of the things that can be done to extract information directly from the AutoSys database