Lec 4
Lec 4
SQL AUTO
INCREMENT Field
Note:
Identity(seed,increment)
DML: Data Manipulation Language
5
OR ID Name City
1 Ahmed Cairo
The SELECT statement allows you to read data from one or more
tables. To write a SELECT statement in MySQL, you follow this
syntax:
SELECT select_list
FROM table_name
WHERE conditions
SQL SELECT – Single Column
14
Distinct allow you to remove all the duplicates from the result.
Category
SELECT DISTINCT Category
FROM Product Gadgets
Photography
Household
Versus
Category
SELECT Category Gadgets
FROM Product Gadgets
Photography
Household
17
SQL SELECT – All Attributes
18
Using the MySQL SELECT statement to retrieve data from all columns
example:
SELECT *
FROM Product
WHERE category=‘Gadgets’
SELECT *
FROM Products
WHERE PName LIKE ‘%Touch%’
Name Employee ID
Ahmed 123
SELECT Ename as Name, Enum as Employee ID Ali 124
FROM Employee
Ola 127
From Employee
Mark Antony 113 114
Amr Moussa 114 Null
Where Super_ssn is null;
Fname Lname
Amr Moussa
Compound Comparison Search Conditions
32
SELECT * Ahmed
Ali
Fahmy
Zidan
111
112
London
Paris
FROM Customer Mark Antony 113 London
$300
SELECT Product_name
From Product
Where Standard_Price Between 100 and 300
OR
SELECT Product_name
From Product
Where Standard_Price >= 100 and Standard_Price < = 300
Using specific values for an attribute
34
Grades
Grades
Name Code Mark
Name Code Mark
John DBS 56
John DBS 0.56
John IAI 72
John IAI 0.72
Mary DBS 60
Mary DBS 0.60
Mark PR1 43
Mark PR1 0.43
Mark PR2 35
Mark PR2 0.35
Jane IAI 54
Jane IAI 0.54
LIMIT Keyword
37
In some DBMS
Select top 1 * from employees where lastName=‘Fadi’
Question
40