Presentation is loading. Please wait.

Presentation is loading. Please wait.

4a. Structured Query Language - SELECT Statement Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis with Spreadsheets.

Similar presentations


Presentation on theme: "4a. Structured Query Language - SELECT Statement Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis with Spreadsheets."— Presentation transcript:

1 4a. Structured Query Language - SELECT Statement Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis with Spreadsheets 1

2 WPC Database What information do we need to retrieve from the database in order to complete some administrative tasks, or help making business decisions? –Who are the employees from the Production department? –How many employees are there in the company? –Can you give me the contact info for Heather Jones? –Who is working on project 1300? –…? 2

3 Structured Query Language Structured Query Language (SQL): –used to query and modify database data Using SQL –Show partial information –Connect related information from different tables –Perform some computation –Process information more efficiently SQL is a language used to send command to a database. Must follow some grammar rules. 3

4 SELECT statement Used to display some data retrieved from the database Basic frame SELECT ColumnName(s) FROM TABLENAME; - Meaning: “Display this (or these) column(s) from that table (all the rows will show).” The letters in red are keywords (reserved for the database to use). They are case-insensitive. 4

5 SELECT statement Select certain columns (and all rows) Example 1, Email list of all employees: SELECT FirstName, LastName, Email FROM EMPLOYEE; Example 2, All projects’ start date and end date, SELECT ProjectName, StartDate, EndDate FROM PROJECT; 5

6 SELECT statement Save a query and give it a meaningful name if the query needs to be executed repeatedly. E.g. AllEmployeeEmail A query can be viewed just like a table, but it’s just a real time snapshot of the table data. Any update to the table will be reflected in the query. Queries are also called views in some database systems. 6

7 SELECT statement Select all columns (and all rows) SELECT * FROM EMPLOYEE; (query necessary?) 7

8 SELECT statement Select only unique values Example 1, show all the project start dates, remove all the duplicate values SELECT DISTINCT startDate FROM PROJECT; 8


Download ppt "4a. Structured Query Language - SELECT Statement Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis with Spreadsheets."

Similar presentations


Ads by Google