1 / 8

4 a . Structured Query Language - SELECT Statement

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

gunda
Download Presentation

4 a . Structured Query Language - SELECT Statement

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  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? • …?

  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.

  4. SELECT statement • Used to display some data retrieved from the database • Basic frame SELECTColumnName(s) FROMTABLENAME; - 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.

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

  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.

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

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

More Related