Presentation is loading. Please wait.

Presentation is loading. Please wait.

INFANL01-3 ANALYSE 3 WEEK 3 March 2015 Institute voor Communication, Media en Informatietechnology.

Similar presentations


Presentation on theme: "INFANL01-3 ANALYSE 3 WEEK 3 March 2015 Institute voor Communication, Media en Informatietechnology."— Presentation transcript:

1 INFANL01-3 ANALYSE 3 WEEK 3 March 2015 Institute voor Communication, Media en Informatietechnology

2 AGENDA ▸ CREATE, ▸ INSERT, SELECT en ▸ UPDATE

3 CREATE

4 ▸ SQL CREATE DATABASE Syntax ▸ The SQL CREATE TABLE Statement ▸ The CREATE TABLE statement is used to create a table in a database. ▸ Tables are organized into rows and columns; and each table must have a name ▸ SQL CREATE TABLE Syntax CREATE DATABASE dbname; CREATE TABLE table_name ( column_name1 data_type(size), column_name2 data_type(size), column_name3 data_type(size),.... );

5 EXAMPLE ▸ See http://www.w3schools.com/sql/sql_create_db.asphttp://www.w3schools.com/sql/sql_create_db.asp ▸ http://www.w3schools.com/sql/sql_create_table.asp

6 INSERT

7 ▸ The SQL INSERT INTO Statement ▸ The INSERT INTO statement is used to insert new records in a table ▸ SQL INSERT INTO Syntax ▸ It is possible to write the INSERT INTO statement in two forms. ▸ The first form does not specify the column names where the data will be inserted, only their values: ▸ The second form specifies both the column names and the values to be inserted: INSERT INTO table_name VALUES (value1,value2,value3,...); INSERT INTO table_name (column1,column2,column3,...) VALUES (value1,value2,value3,...)

8 EXAMPLE ▸ See: http://www.w3schools.com/sql/sql_insert.asp

9 SELECT

10 ▸ The SQL SELECT Statement ▸ The SELECT statement is used to select data from a database. ▸ The result is stored in a result table, called the result-set. ▸ SQL SELECT Syntax ▸ It is possible to write the INSERT INTO statement in two forms. ▸ and SELECT column_name,column_name FROM table_name; SELECT * FROM table_name;

11 EXAMPLE ▸ See http://www.w3schools.com/sql/sql_select.asp

12 UPDATE

13 ▸ The SQL UPDATE Statement ▸ The UPDATE statement is used to update existing records in a table. ▸ SQL UPDATESyntax ◦ Notice the WHERE clause in the SQL UPDATE statement! ◦ The WHERE clause specifies which record or records that should be updated. If you omit the WHERE clause, all records will be updated! UPDATE table_name SET column1=value1,column2=value2,... WHERE some_column=some_value;

14 EXAMPLE ▸ See http://www.w3schools.com/sql/sql_select.asp

15 JOIN

16 JOINS ▸ SQL JOIN ▸ An SQL JOIN clause is used to combine rows from two or more tables, based on a common field between them. ▸ The most common type of join is: SQL INNER JOIN (simple join). An SQL INNER JOIN return all rows from multiple tables where the join condition is met ▸ SQL INNER JOIN Syntax ▸ Different SQL JOINs SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate FROM Orders INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID; INNER JOIN: Returns all rows when there is at least one match in BOTH tables LEFT JOIN: Return all rows from the left table, and the matched rows from the right table RIGHT JOIN: Return all rows from the right table, and the matched rows from the left table FULL JOIN: Return all rows when there is a match in ONE of the tables

17 EXAMPLE ▸ See http://www.w3schools.com/sql/sql_join.asp

18


Download ppt "INFANL01-3 ANALYSE 3 WEEK 3 March 2015 Institute voor Communication, Media en Informatietechnology."

Similar presentations


Ads by Google