Download presentation
Presentation is loading. Please wait.
1
WEEK# 12 Haifa Abulaiha haifa.abulaiha@mail.wvu.edu November 02, 2015 1
2
SQL Structure Query Language. SQL is a standard language to define, manipulate and retrieve data in database. Basic SQL keywords: –SELECT –FROM –WHERE –ORDER BY 2
3
SQL SELECT Select statement is used to retrieve data from tables in a database. Select specifies the fields to include in the query. FROM key word specifies the tables where the fields can be found. Example: SELECT Students.FirstName, Students.LastName FROM Students; SELECT * FROM Students; 3
4
SQL ORDER BY Determines how the rows will be sorted. Example: SELECT * FROM Students ORDER BY Students.LastName, Students.FirstName; SELECT * FROM Students ORDER BY Students.LastName DESC; 4
5
SQL JOIN To include results from multiple tables. JOIN –INNER –LEFT –Right Example: SELECT Students.FirstName, Students.LastName, StudentAddresses.Address, FROM Students INNER JOIN StudentAddresses ON Students.StudentID=StudentAddresses.StudentID; 5
6
SQL GROUP BY To calculate statistics Example: SELECT Students.FirstName, Students.LastName, Count (StudentAddresses.Address) AS CountOfAddressType FROM Students INNER JOIN StudentAddresses ON Students.StudentID=StudentAddresses.StudentID GROUP BY Students.FirstName, Students.LastName; 6
7
SQL WHERE Sets the criteria that records must match to be included in the results. If the query does not include WHERE, the query will return all records. Example: SELECT Students.FirstName WHERE Students.ID = “123456789”; 7
8
SQL INSERT To insert a new record in a table in the database. Example: INSERT INTO Students VALUES (“Sarah”, “Joseph”, “123456789”); INSERT INTO Students (FirstName, LastName, StudentID) VALUES (“Sarah”, “Joseph”, “123456789”); 8
9
SQL UPDATE To update records in a table in the database. Example: Update StudentAddresses SET StudentAddresses.AddressType = “Mailing” WHERE StudentAddresses.AddressType=“Home”; 9
10
SQL DELETE To delete records from a table in the database. Example: DELETE FROM StudentAddresses WHERE StudentAddresses.AddressType=“Parent”; 10
11
IMPORTANT DATES Due MyITLab Lesson DMonday 11/02 Homework # 5Friday 11/06 Exam 2 Section 19Monday 11/09 Exam 2 Section 21Wednesday 11/11 MyITLab Bonus Project # 2Friday 11/13 MyITLab Lesson EMonday 11/16 11
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.