Lecture 06 Query by Example
Lecture 06 Query by Example
QUERY-BY-EXAMPLE
1
Objectives
The main features of Query-By-Example (QBE).
• The types of query.
• How to use QBE to build queries to select fields and
records.
• How to use QBE to target single or multiple tables.
• How to perform calculations using QBE.
• How to use advanced QBE facilities including parameter,
find matched, find unmatched, crosstab, and auto-
lookup queries.
• How to use QBE action queries to change the content of
tables.
2
SQL server
• Windows 10
– To open SQL Server Configuration Manager.
• On the Start Page > type “SQLServerManager13.msc”
(for SQL Server 2016)
• Or - Open > Computer Manager
> Services and Applications
> SQL Server Configuration.
3
Microsoft SQL Server Management Studio (SSMS)
Developer Developer
Machine 1 Machine 1
Database Server
Developer Developer
Machine 1 Machine 1
5
Object Explorer window
Type queries
Select database
9
Structured Query Language
• The aim is to create tblPerson and tblGender tables and establish
primary key and foreign key constraints using a query.
Create table tblPerson
(
PersonID int NOT NULL Primary Key,
[Name] nvarchar(50),
Email nvarchar(50), tblPerson tblGender
PersonID GenderID
GenderID int
Name Gender
)
Email
GenderID
Create table tblGender
(
GenderID int NOT NULL Primary Key,
Gender nvarchar(50) NOT NULL
)
11
Structured Query Language
Insert Into tblGender Values (1,'Male'),
(2, 'Female'),
(3, 'Unknown')
12
How to input the value in table
department
departID
departName
departPhone
headOfDepart
dateOperate lecturer
lecID
lecName
Salary
lecturer * gender
lecID DoB
lecName lecAddress
Salary leader
gender DepID
DoB
lecAddress
leader
departID
13
14
15
16
Thank you for your listen
End of lecture 06
17