Professional Documents
Culture Documents
Week11 12
Week11 12
________Baniwalid _______
(SQL)
Week 11
Mustafa Abuali spring 2017
Outline
Working with tables.
How to create table.
How to drop table.
How to alter table.
Working with constrains.
Working with Data.
Insert new data rows .
Update existing data.
Delete existing row.
Retrieving Data.
Select statement .
Where .
Join table .
Grouping data.
Sorting data.
Introduction
Make a request
(SQL query)
MySQL Client
Server Get results Program
WARNING
Always assume that everything is case
sensitive, especially table names.
Working with table (CREATE TABLE )
Create table
The DROP Command
mysql>
Alter Table
Alter Table
Working with Data.
The inset statement allows to insert a single or multiple records into the table.
Here you can specify the column as you write . By attention with PK,NOT NULL
For example :
Update data .
The inset statement allows to UPDATE a single or multiple records into the table.
The syntax is .
Here you apply the changes to all values stored in this column .there is problem
Here all the value of name column will be changed into “HP”.
UPDATE with condition
The syntax for update statment is :
Here only the supplier_name with the value IBM will be changed to HP
DELETE existing data
The inset statement allows to DELETE a single or multiple records into the
table.
The syntax is .
Here you will delete all the data rows from the table .
Here you will delete all data inside the supplier table . Not table !!!(Drop !!!!*)
Delete with condition
The syntax is :
Example:
Here you delete only the data rows that meet the where condition .
Retrieving Data.(select statement)
The select statement allows to Retrieve a single or multiple records from one
or more table in your database .
The syntax is
For Example :
Tables
Select statement (where)
____For Example:____
Simple SQL Query
SELECT *
FROM Product
WHERE category=‘Gadgets’
Category
SELECT DISTINCT category Gadgets
FROM Product
Photography
Household
Compare to:
Category
Gadgets
SELECT category Gadgets
FROM Product
Photography
Household
32