Introduction to Query Language and SQL. Basic Query Language Operators Selection Projection Join Aggregates –Sum, Count, Max, Min, Avg SubTotal Calculated.

Slides:



Advertisements
Similar presentations
Working with Tables 1 of 5. Working with Tables 2 of 5.
Advertisements

Query Methods (SQL). What is SQL A programming language for databases. SQL (structured Query Language) It allows you add, edit, delete and run queries.
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Query-By-Example (QBE) 2440: 180 Database Concepts.
Querying Database ISYS 363. Basic Query Language Operations Selection Projection Join Aggregates: Max, Min, Sum, Avg, Count –Totals and SubTotals –GroupBy.
Session 4 SQL Structured Query Language. SQL Modes of use –Interactive –Embedded Purpose –Create database –Create, Read, Update, Delete.
Chapter 8 Special-Purpose Languages. SQL SQL stands for "Structured Query Language". Allows the user to pose complex questions of a database. It also.
Structured Query Language Review ISYS 650. Language Overview Three major components: –Data definition language, DDL Create, Drop and Alter Tables or Views.
VB.NET Database Tools ISYS Net Applications OLE DB Provider OLE DB Data Source OLE DB Provider ODBC Data Source SQL Server Data Source SQL Server.Net.
Coding ADO.NET Objects: Connection, Command, DataReader.
Introduction to Structured Query Language, SQL. SQL Select Command SELECT * FROM tableName WHERE criteria;
Coding ADO.NET Objects: Connection, Command, DataReader.
Basic SQL Select Commands. Basic Relational Query Operations Selection Projection Natural Join Sorting Aggregation: Max, Min, Sum, Count, Avg –Total –Sub.
Coding ADO.NET Objects: Connection, Command, DataReader.
SQL SQL stands for Structured Query Language SQL allows you to access a database SQL is an ANSI standard computer language SQL can execute queries against.
Querying Database ISYS 363. Basic Query Language Operations Selection Projection Join Aggregates: Max, Min, Sum, Avg, Count –Totals and SubTotals –GroupBy.
Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages.
Querying Database. Basic Query Language Operations Selection Projection Join Aggregates: Max, Min, Sum, Avg, Count –Totals and SubTotals –GroupBy Calculated.
Structured Query Language. Brief History Developed in early 1970 for relational data model: –Structured English Query Language (SEQUEL) –Implemented with.
Concepts of Database Management Sixth Edition
Introduction to Structured Query Language SQL. SQL Select Command SELECT * FROM tableName WHERE criteria;
Relational Operators, SQL, and Access Query ISYS 562.
Microsoft Access 2010 Chapter 7 Using SQL.
Database Processing with JSP ISYS 350. Example: Enter CID in a box and retrieve the customer record.
Database Processing with JSP ISYS 350. Example: Enter CID in a box and retrieve the customer record.
Relational DBs and SQL Designing Your Web Database (Ch. 8) → Creating and Working with a MySQL Database (Ch. 9, 10) 1.
Structured Query Language. Brief History Developed in early 1970 for relational data model: –Structured English Query Language (SEQUEL) –Implemented with.
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 4 BACKNEXTEND 4-1 LINKS TO OBJECTIVES Query Design Query Criteria Modify a Query Using OR.
Database Processing with JSP ISYS 350. Example: Enter CID in a box and retrieve the customer record.
Agenda TMA01 M876 Block 3 – Using SQL Structured Query Language - SQL A non-procedural language to –Create database and relation structures. –Perform.
SQL: Data Manipulation Presented by Mary Choi For CS157B Dr. Sin Min Lee.
1 TAC2000/ Protocol Engineering and Application Research Laboratory (PEARL) Structured Query Language Introduction to SQL Structured Query Language.
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
BY SATHISH SQL Basic. Introduction The language Structured English Query Language (SEQUEL) was developed by IBM Corporation, Inc., to use Codd's model.
Part II. Query Types On the design query table pane, right click and the cascading window will appear.
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.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
Introduction to Access ISYS 363. Creating a New Database MS Office button/New –Blank database –New database name and location.
Command Object’s ExecuteNonQuery Method ISYS 512.
DATA RETRIEVAL WITH SQL Goal: To issue a database query using the SELECT command.
Database UpdatestMyn1 Database Updates SQL is a complete data manipulation language that can be used for modifying the data in the database as well as.
Querying Database ISYS 363.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
Database Processing with JSP ISYS 350. Example: Enter CID in a box and retrieve the customer record.
Introduction to Access BUS 782. Creating a New Database MS Office button/New –Blank database –New database name and location.
Coding ADO.NET Objects: Connection, Command, DataReader.
Introduction to Access ISYS 363. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages.
CS 111 – Nov. 8 Databases Database Management Systems (DBMS) Structured Query Language (SQL) Commitment –Please review sections 9.1 – 9.2.
1 VIEW Structured Query Language (SQL) - Part IV.
Drill Consider the following tables with the following fields: Student: FName, LName, StudentID, Age, Yr, Course Grades: ID, P1, P2, P3 1.Display the.
Database Processing with JSP ISYS 350. Example: Enter CID in a box and retrieve the customer record.
Introduction to Access ISYS 363. Access Objects Tables –Open a table: Double click the table name –Home/View: Datasheet view Design view Queries Forms.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
SQL LANGUAGE TUTORIAL Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
Advanced Accounting Information Systems Day 12 Understanding the SQL Language September 21, 2009.
Database Processing with JSP ISYS 350. Database Applications Applications Database Server Queries/Updates Results.
SQL Reminder Jiankang Yuan Martin Lemke. SQL Reminder - SELECT SELECT column_name1, column_name2, … FROM table_name SELECT * FROM table_name.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
SQL SQL Ayshah I. Almugahwi Maryam J. Alkhalifa
Coding ADO.NET Objects: Connection, Command, DataReader
The Database Exercises Fall, 2009.
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
Database Processing with JSP
Querying Database ISYS 363.
Access: SQL Participation Project
Database Design and Development
Coding ADO.NET Objects: Connection, Command, DataReader
Aggregate functions Objective- understand and able to use aggregate functions in select statement Aggregate functions are used to implement calculation.
Shelly Cashman: Microsoft Access 2016
Command Object’s ExecuteNonQuery Method
Presentation transcript:

Introduction to Query Language and SQL

Basic Query Language Operators Selection Projection Join Aggregates –Sum, Count, Max, Min, Avg SubTotal Calculated field

SQL Insert Command INSERT INTO tableName VALUES (field values separated by commas); INSERT INTO tableName (Column names separated by commas)VALUES (field values separated by commas); Ex 1. Customer table with CID, CNAME, CITY, RATING. a. INSERT INTO CUSTOMER VALUES (‘C1’, ‘SMITH’, ‘SF’, ‘A’); b. INSERT INTO CUSTOMER (CID, CNAME,RATING) VALUES (‘C1’, ‘SMITH’, ‘A’); Ex 2. Orders table with OID, OrderDate, CID, SalesPerson INSERT INTO ORDERS VALUES (‘O11’, #9/28/02#, ‘C1’, ‘Peter’);

Creating A String Containing SQL Insert Command Assuming the four fields of the new customer record are entered in textboxes: Dim strSQLInsert As String strSQLInsert = "Insert into Customer values ('" strSQLInsert = strSQLInsert & TextBox1.Text & "','" & TextBox2.Text & "','" strSQLInsert = strSQLInsert & TextBox3.Text & "','" & TextBox4.Text & "')"

SQL Delete Command DELETE FROM tableName WHERE criteria; Ex 1. Delete a record from the Customer table. DELETE FROM CUSTOMER WHERE CID = ‘C1’;

Creating A String Containing SQL Delete Command Assuming the deleted record’s ID is selected from a list box: Dim strSQLDel As String = “DELETE FROM CUSTOMER WHERE CID = ‘“ strSQLDel = strSQLDel & ListBox1.SelectedItem & "'"

SQL Update Command UPDATE tableName SET field = new value WHERE criteria; Ex. 1. UPDATE CUSTOMER SET RATING = ‘A’ WHERE CID=‘C1’; 2. UPDATE EMPLOYEE SET SALARY = SALARY*1.05

Creating A String Containing SQL Update Command Assuming the CID is selected from a list box, and the new rating is entered in a text box: Dim strSQLUpd As String = "Update customer set rating = '" & textbox1.text & "'" strSQLUpd = strSQLUpd & " where cid='" & ListBox1.SelectedItem & "'"

SQL Select Command 1. SELECT * FROM tableName WHERE criteria; Ex. SELECT * FROM CUSTOMER WHERE RATING = ‘a’; 2. SELECT fields FROM tableName WHERE criteria; Ex. SELECT CID, CNAME, RATING FROM EMPLOYEE WHERE CITY = ‘sf’;

Aggregates 1.SELECT COUNT(CID) AS custCount FROM CUSTOMER; 2.SELECT COUNT(EID) AS empCount, SUM(SALARY) AS totalSalary, AVG(SALARY) AS avgSalary FROM EMPLOYEE; 3. Group By: Ex. SELECT CITY, COUNT(CID) As CustCount FROM CUSTOMERGROUP BY CITY; Ex. SELECT SEX, AVG(SALARY) AS avgSalary FROM EMPLOYEE GROUP BY SEX; Note: Alias CustCount

Creating A String Containing SQL Select Command Assuming the rating is selected from a list box: dim strSQL as string = "select * from customer where rating = ‘“ strSQL = strSQL & ListBox1.SelectedItem & "‘”