SlideShare uma empresa Scribd logo
1 de 88
Baixar para ler offline
Accelerated Computer Training for Working Professionals Admissions Case
Orange Coast Database Associates Course (800)355-9855 or http://ocdatabases.itgo.com
Orange Coast
Database Associates
Specializing in Microsoft Office,
Access, SQL, and related technologies
Classes custom designed forWorking Professionals
http://www.dhdursoassociates.com
San Juan Capistrano, CA
(800)355-9855
AIN102 Microsoft Access Queries
Admissions AIN1021
AIN102 – Access Query Design
Introduction to Access Queries for
experienced Windows users
P.O. Box 6142
Laguna Niguel, CA 92607
949-489-1472
http://www.d2associates.com
AdmissionsAIN1022
AIN102 Contact Information
P.O. Box 6142
Laguna Niguel, CA 92607
949-489-1472
http://www.d2associates.com
slides.1@dhdursoassociates.com
Copyright 2001-20011 All rights reserved.
AIN102 Notes
 This course is based on an earlier course,
SQL200A, which was focused on using SQL in
the Access environment. As such the
screenshots still reflect SQL view as well the
Query Designer view. This is actually a plus.
AdmissionsAIN1023
AdmissionsAIN1024
 Introduction (s)
 Facilities
 Course Packet (May vary by course or class)
– Student questionnaire in front
– Collaterals (Map, Catalog, Etc.)
– PowerPoint handouts for all sessions
– Evaluation form in back
– Training Certificate
AIN102 – Access Query Design
AdmissionsAIN1025
Orange Coast Database Associates
 Loose association of local University instructors and IT
Professionals.
 Started in 2004
 Training
– Open Enrollment (public classes in San Juan Capistrano using
standardized material)
– On-site (custom classes for groups)
– Private desk side training for individuals
 Consulting & Programming (incl. offshore)
AdmissionsAIN1026
AdmissionsAIN1027
 Quick pace for experienced windows users
 Assumes some prior knowledge of Access
 End-user, not programmer, oriented
 Somewhat structured towards personal use for
analysis and reporting
AIN102 – Access Query Design
AdmissionsAIN1028
 Select Queries
– Filter Criteria
– Calculations
– Joins
– Grouping
 Action Queries
– Maketable
– Append
– Update
– Delete
 Union
Course Topics:
AIN102 – Access Query Design
AdmissionsAIN1029
Approach:
SQL View Used in code; but helpful in
understanding what a query
does
Query Designer Use to construct queries
Access has many ways to accomplish tasks. Queries can be
constructed using SQL View or the Query Designer. This
course focuses on the latter.
AIN102 – Access Query Design
AdmissionsAIN10210
 2 Sessions
 Lecture
 Demo
 Extensive student “hands-on”
 Exercises are cumulative – later
examples build on objects created
earlier
Course Format:
AIN102 – Access Query Design
AIN102 Resources
 Manuals can be downloaded from SlideShare.
 Slides can be viewed on SlideShare…
http://www.slideshare.net/OCDatabases
AdmissionsAIN10211
AdmissionsAIN10212
 Session 1
– access-qdes-s1-ad.ppt
 Session 2
– access-qdes-s2-ad.ppt
Course Schedule (3 hour sessions):
AIN102 – Access Query Design
1
AIN102
Access Query Design
Orange Coast Database Associates, Inc.
949-489-1472
http://www.dhdursoassociates.com
AIN102
Access Query Design
Module 1 – Relational Database Background,
Basic Single Table Retrieval Operations
2
AIN102 Module 13 Admissions AIN102 Module 13
AIN102
 Session 1 – Review of Relational Databases
and Single Table Retrieval, Functions and
Operators
 Session 2 – Multi-table retrieval, Subqueries,
Unions, Action Queries, Indexes
AIN102 Module 14 Admissions AIN102 Module 14
AIN102
 Lecture/discussion with demonstrations
– Mostly practical, but a dose of “theory”
 Assumes some familiarity with MS Access
 Hands-on
 Exercises (Mostly cumulative)
 About 3-4 hours per module
 Frequent breaks
3
AIN102 Module 15 Admissions AIN102 Module 15
Module 1
 Concepts
– Relational
databases
– SQL
– Access Query
Designer
 SELECT Query
– Basic
– Filter criteria
– Complex criteria
• Field Operations
• Functions
• Operators
• Calculated fields
• Concatenation
AIN102 Module 16 Admissions AIN102 Module 16
Microsoft Access Query Design
 Course focus is Microsoft Access Query Design
 Queries are widely used for:
– Database administration
– Enterprise application development
– Data driven web sites
– Retrieving and modifying data in MS Access databases
 A foundation skill for eBusiness and almost all major
business applications that use relational databases
4
AIN102 Module 17 Admissions AIN102 Module 17
Access Query Design and SQL
 Class database will be MS Access – the SQL
engine Access uses is called JET
 A basic knowledge of Access is assumed
 Focus of this class will be on the query
designer, with SQL used from time-to-time to
explain concepts
AIN102 Module 18 Admissions AIN102 Module 18
Relational Database Basics
 Storage
 Databases
 Tables
 Rows
 Columns
 Indexes
 Views
 SQL interface
5
AIN102 Module 19 Admissions AIN102 Module 19
Storage
 In Access one file with extension mdb. I.e
mydatabase.mdb.
 Database splitter can be used to split it into
two parts – a front end and a back end.
 Interface to physical storage via the “JET”
database engine. This is the behind-the
scenes-workhorse.
AIN102 Module 110 Admissions AIN102 Module 110
Databases
 In the Access world refers to all objects
stored in the mdb.
– Tables
– Queries
– From
– Reports
– Macros
– Code modules
6
AIN102 Module 111 Admissions AIN102 Module 111
Relational Database Table
AIN102 Module 112 Admissions AIN102 Module 112
Sample Access Database
7
AIN102 Module 113 Admissions AIN102 Module 113
Database Relationships
AIN102 Module 114 Admissions AIN102 Module 114
Approaching Query Design
 Try to build queries a step at a time
 Save existing queries that are working
as you like; modify them with a new
name when building a modified query
 Try looking at the generated SQL code
from time-to-time
8
AIN102 Module 115 Admissions AIN102 Module 115
Query Types
 Select
 Action
– Update
– Delete
– Insert
– Maketable
 Special use queries
– Data Definition Language (DDL)
– Union
– SQL pass-through
AIN102 Module 116 Admissions AIN102 Module 116
DDL
 Data definition language (DDL) to create and
modify tables, etc.
– Create, alter, drop, etc.
– Must be “hand-coded” in Access
– But can be useful for database administration
 Done in MS Access via SQL Specific Queries
– Will not be covered in the course
9
AIN102 Module 117 Admissions AIN102 Module 117
MS Access DDL Queries
AIN102 Module 118 Admissions AIN102 Module 118
DCL
 Data Control Language (DCL) to control user
rights, etc.
– Grant
– Revoke
– Constraints
 Used primarily in enterprise databases
 Can be done in Access but not covered in
this course
10
AIN102 Module 119 Admissions AIN102 Module 119
DML
 Data Manipulation Language (DML)
– Select Query
– Append Query
– Update Query
– Delete Query
– Maketable Query (a special type of Select)
– Union Query (really combined Selects)
 MS Access Query Designer will create these
statements “behind the scenes”
AIN102 Module 120 Admissions AIN102 Module 120
MS Access Action Queries
11
AIN102 Module 121 Admissions AIN102 Module 121
Other Access Queries
 Crosstab
 Pass Through – used to pass an SQL
statement directly to a back end database
w/out processing by Access
AIN102 Module 122 Admissions AIN102 Module 122
Sample Database
 Before we continue…
 Load the sample database if you haven’t
already
12
AIN102 Module 123
Query Designer
Admissions AIN102 Module 123
Right click anywhere
for SQL View
Double click or drag
to add a field
Double click to add a
table
AIN102 Module 124 Admissions AIN102 Module 124
SELECT Queries
Basic Syntax:
Select column-list or *
From table-list
* Means all columns
13
AIN102 Module 125 Admissions AIN102 Module 125
MS Access SELECT Query
Drag and Drop
or double click
AIN102 Module 126 Admissions AIN102 Module 126
MS Access SELECT SQL
14
AIN102 Module 127 Admissions AIN102 Module 127
Simple Select Query Results
AIN102 Module 128 Admissions AIN102 Module 128
SELECT w/ Where
Filters retrieved rows
Syntax:
SELECT column-list
FROM table-list
WHERE selection-criteria
15
Admissions AIN102 Module 129
Comparison Operators
 < less than
 > greater than
 <= less than or equal
 >= greater than or equal
 = equal
 <> not equal
AIN102 Module 130 Admissions AIN102 Module 130
SELECT w/ WHERE
16
AIN102 Module 131 Admissions AIN102 Module 131
SELECT w/ WHERE
AIN102 Module 132 Admissions AIN102 Module 132
SELECT w/ WHERE Results
17
AIN102 Module 133 Admissions AIN102 Module 133
Complex Filters
Follows normal boolean logic
Select PatID, LastName, etc…
From patients
Where (LastName = “Thomas” or
birthdate < #1/1/95#) and city =
“Corona”)
AIN102 Module 134 Admissions AIN102 Module 134
Complex Filter
AND
18
AIN102 Module 135 Admissions AIN102 Module 135
Select w/ Complex Where
AIN102 Module 136 Admissions AIN102 Module 136
Complex Filter Results
19
AIN102 Module 137 Admissions AIN102 Module 137
Special Operators
 LIKE
 IN
 BETWEEN
 IS NULL
AIN102 Module 138 Admissions AIN102 Module 138
Like (“Wild Card Matches”)
 Where customer_last_name like “Jo*”
– *= string of characters
 Where customer_last_name like “Jo?”
– ? = exactly one character
Access actually allows more sophisticated Unix style
search patterns as well – see help.
20
AIN102 Module 139 Admissions AIN102 Module 139
LIKE
Names ending in “S”
AIN102 Module 140 Admissions AIN102 Module 140
LIKE
Names ending in “S”
21
AIN102 Module 141 Admissions AIN102 Module 141
LIKE Results
AIN102 Module 142 Admissions AIN102 Module 142
IS NULL
Select columnns
From clients
Where zip IS NULL
SQL (including JET) uses three valued logic.
Must use IS NULL to test for unknowns. A null is
NOT the same as blank or empty.
22
AIN102 Module 143 Admissions AIN102 Module 143
IS NULL
AIN102 Module 144 Admissions AIN102 Module 144
IS NULL
23
AIN102 Module 145 Admissions AIN102 Module 145
IS NULL Results
OK. Now try finding all patients with a blank address. Was
the above row retrieved? Why or why not?
AIN102 Module 146 Admissions AIN102 Module 146
IN
Select *
From patients
Where lastname IN (“Smith”,
“Thomas”, “Juarez”)
Note: what is inside parentheses is a list. Later we
will replace the list with a subquery which
generates the list items.
24
AIN102 Module 147 Admissions AIN102 Module 147
IN
AIN102 Module 148 Admissions AIN102 Module 148
IN
List of values
25
AIN102 Module 149 Admissions AIN102 Module 149
SELECT w/in IN Results
AIN102 Module 150 Admissions AIN102 Module 150
BETWEEN
SELECT *
FROM admissions
WHERE admit_date BETWEEN
#10/1/2001# and #12/31/2001#
Note: between is inclusive
26
AIN102 Module 151 Admissions AIN102 Module 151
BETWEEN
AIN102 Module 152 Admissions AIN102 Module 152
BETWEEN Results
27
AIN102 Module 153 Admissions AIN102 Module 153
Removing Duplicates
SELECT DISTINCT PatNo
FROM admissions
List once each employee who has a
labor ticket
Removes duplicate rows from result set
AIN102 Module 154 Admissions AIN102 Module 154
DISTINCT
28
AIN102 Module 155 Admissions AIN102 Module 155
Distinct Results
W/out Distinct With Distinct
AIN102 Module 156 Admissions AIN102 Module 156
Sorting – ORDER BY
DESC will sort in descending order
Basic syntax:
SELECT column list
FROM table list
WHERE selection criteria
ORDER BY column list [DESC]
29
AIN102 Module 157 Admissions AIN102 Module 157
Sorting – ORDER BY
Select *
From patients
Where state in(“CA”, “OR”, “WA”)
Order by birthdate desc
Example:
List patients in Pacific Coast sorted
by youngest to oldest
AIN102 Module 158 Admissions AIN102 Module 158
Sorting – ORDER BY
Note: modify the “select_in” query
30
AIN102 Module 159 Admissions AIN102 Module 159
Sorting – ORDER BY
AIN102 Module 160 Admissions AIN102 Module 160
Sorting – Results
31
AIN102 Module 161 Admissions AIN102 Module 161
Query/SQL Exercises
 List all patient numbers, etc. for patients who co-
paid more than $20; sort by co-pay amount,
largest first
 List diagnostics that contain b, d, or q in the
diagnostic code
 List the patient id’s for admissions in the fall (Sep,
Oct, Nov) of 2001 and 2002
AIN102 Module 162 Admissions AIN102 Module 162
Calculated Fields
Example:
Select a + b as result
Syntax:
SELECT expression AS new
column name
Result is a “column
alias”
32
AIN102 Module 163 Admissions AIN102 Module 163
Calculated Fields
New column name
Follow name with “:”
AIN102 Module 164 Admissions AIN102 Module 164
Calculated Fields
33
AIN102 Module 165 Admissions AIN102 Module 165
Calculated Fields - Results
AIN102 Module 166 Admissions AIN102 Module 166
Concatenation
 “Adds” two character fields using “&” symbol
 Useful for formatting names, addresses, etc.
 Example:
– Select firstname & “ “ & lastname as fullname
34
AIN102 Module 167 Admissions AIN102 Module 167
Concatenation
Sort, but don’t
show
AIN102 Module 168 Admissions AIN102 Module 168
Concatenation
35
AIN102 Module 169 Admissions AIN102 Module 169
Concatenation
Single column with full
name, sorted by last name
Tip: handy for reports
AIN102 Module 170 Admissions AIN102 Module 170
SQL Exercises
 List all the patients with a “fullname” field;
sorted by last name. Add a calculated field
which shows their loaded copay (copay *1.5).
Show the fullname, but not the individual
names.
36
AIN102 Module 171 Admissions AIN102 Module 171
End Session 1
Next session: multi-table
operations, subqueries, unions,
action queries, indexes
1
Admissions AIN102 Module 21
AIN102
Access Query Design
Module 2
P.O. Box 6142
Laguna Niguel, CA 92607
949-489-1472
http://www.d2associates.com
Admissions AIN102 Module 22
Module 2
 Part 1
– Miscellaneous Functions
 Strings
 Dates
– Summaries (Grouping)
 Part 2 – Joins,
subqueries
– Inner join
– Outer joins
– Subqueries
 Multi-valued
 Single-valued
• Part 3 – Unions,
Action Queries,
Indexes
• Unions
• Maketable Query
• Delete
• Append
• Update
• Indexes
2
Admissions AIN102 Module 23
String Manipulation
 Trim
 Substring
 UCase, LCase
 Left, Right
 See help for others
Admissions AIN102 Module 24
String Manipulation
3
Admissions AIN102 Module 25
String Manipulation
Admissions AIN102 Module 26
String Example
4
Admissions AIN102 Module 27
Date Functions
 Numerous date functions
– DatePart
– DateDiff
– DateAdd
– Etc.
 Often used:
– Year
– Month
 Ex: where year(birthdate) = 1999
Admissions AIN102 Module 28
DateDiff
 How long did patients stay in weeks?
5
Admissions AIN102 Module 29
DateDiff results
Note: Access has many date functions with many options.
Admissions AIN102 Module 210
Ex: Date Function – Month()
6
Admissions AIN102 Module 211
Ex: Date Function – Month()
Admissions AIN102 Module 212
Result of Month Function
7
Admissions AIN102 Module 213
Summary Functions
 Count
 Sum
 Min
 Max
 Avg
 Often used in conjunction
with grouping
Admissions AIN102 Module 214
Summary Functions in Access
Click the sum symbol
Adds a total row
8
Admissions AIN102 Module 215
Summary Functions - Syntax
Basic syntax:
SELECT function(column)
FROM table
WHERE filter-condition
GROUP BY column-list
HAVING group-filter
Group by all columns to left of one(s)
you to want aggregate
Admissions AIN102 Module 216
Simple Column Summaries
This query counts patient admissions In the year 2001
9
Admissions AIN102 Module 217
Simple Column Summaries
Admissions AIN102 Module 218
Simple Record Count
10
Admissions AIN102 Module 219
“The COUNTS”
 Count(*) – counts records
 Count(fieldname) – counts non–null
occurrences of field name
 Count (distinct fieldname) – counts distinct
occurrences, but not supported in access
Admissions AIN102 Module 220
Grouping
 Organizes results into summary rows, one per
group
 Groups can have sub groups which have sub
groups and so on….
11
Admissions AIN102 Module 221
GROUP BY in Query Designer
Admissions AIN102 Module 222
GROUP BY Problem
Not an aggregate
or group
You will see this error a lot. Not to worry. It happens to everyone!
12
Admissions AIN102 Module 223
Group By Results
Admissions AIN102 Module 224
Having
 Restricts the groups returned
 Operates on the groups after they have been
formed
HAVING
(((Admissions.Diag_Code)
Like "a*"))
13
Admissions AIN102 Module 225
Having – SQL View
 Restricts the groups returned
 Operates on the groups after they have been formed
Admissions AIN102 Module 226
HAVING
14
Admissions AIN102 Module 227
HAVING Results
Admissions AIN102 Module 228
AIN102
Access Query Design
Part 2 – Joins, Subqueries
15
Admissions AIN102 Module 229
Database Design
Diagram of the database for reference in joins
Admissions AIN102 Module 230
Joins
 Used to combine columns from more
than one table
 Several types
– Inner
– Outer
 Left
 Right
– Others (not covered)
 Full Outer (Not supported in Access)
 Cross
 Self
 Non equal
16
Admissions AIN102 Module 231
Inner Join
 Pairs each row from first table with
corresponding row from second table over
the “join column” or “linking column”
 The result only contains rows where there is
a match over the join column in both tables
 The default join in most databases
Admissions AIN102 Module 232
Inner Join Syntax
Basic SQL 92 Syntax:
SELECT column-list
FROM table1 [AS alias]
INNER JOIN table2 [AS alias]
ON join-condition
17
Admissions AIN102 Module 233
Table Aliases
 Shorthand name for a table
 Used in more complex queries
Select t.id, s.lname
From _traveler as t
Inner join xLU_Staff as s
On t.staffid = s.staffid
Table alias
Admissions AIN102 Module 234
Inner Join Basic SQL Example
Basic Example: Add patient names to
admissions data
Two join tables
Join condition
18
Admissions AIN102 Module 235
Inner Join Query Design
Admissions AIN102 Module 236
Inner Join Results
19
Admissions AIN102 Module 237
Inner Join over Multiple columns
 Note that that the join condition can apply to
multiple columns if desired
 Used with composite keys
Select ….
From tablea as ta
Inner join tableb as tb
On ta.key1 = tb.key1
And ta.key2 = tb.key2
Admissions AIN102 Module 238
Joining More than Two Tables
 Can join several tables in one select
 Try to limit to three or four
 Demonstration example
20
Admissions AIN102 Module 239
3 Table Query Results
Admissions AIN102 Module 240
More on Aliases
 Can be set in Query
Designer, too, by
right clicking on a
table
 Useful for debugging
top level queries as
we shall see later
21
Admissions AIN102 Module 241
Outer Joins
 Left
– selects all rows from the left or first table, even if no match
exists in the other table
– Widely used in commercial practice, esp. for reporting
 Right
– same idea but all rows from right table
 Full
– all rows from both tables; not supported in Access
Admissions AIN102 Module 242
Left Outer Join
Basic SQL 92 Syntax:
SELECT column-list
FROM table1
LEFT JOIN table2
ON join-condition
22
Admissions AIN102 Module 243
Left Outer Join
(Right click on relationship to edit)
Admissions AIN102 Module 244
Left Outer Join
 Modify your prior inner join to
use a left join
 Save as qryLeft_Admit
 Now run both the inner and
left joins
 What is the difference?
23
Admissions AIN102 Module 245
Left Outer Join Results
Admissions AIN102 Module 246
Subqueries
 One select statement embedded in another
 Can be nested multiple levels deep
 In Access query designer can be placed in
criteria row or field row
24
Admissions AIN102 Module 247
Multi-valued Subquery
 A type of subquery that compares to a list
 Ex: find all diagnostic codes with no admissions
 Commonly encountered in commercial practice
Admissions AIN102 Module 248
Multi-valued Subquery
 Place subquery in criteria row
25
Admissions AIN102 Module 249
Multi-valued Subquery Result
No one was ever admitted with these diagnoses.
Admissions AIN102 Module 250
Single-valued Subquery
Subquery that returns a single value
Find all admissions with stays greater than the average stay
26
Admissions AIN102 Module 251
Single-valued Subquery
Subquery that returns a single value
Admissions AIN102 Module 252
Single-valued Subquery Result
27
Admissions AIN102 Module 253
Queries using Queries
 Queries can be read just like a table
 Some are updateable
 Using a query as a source for another query
very common in Access – especially for
complicated queries
 In a “back end” database such as Oracle or
SQL Sever you would use a View
Admissions AIN102 Module 254
Queries using Queries
Filter the prior query ( a little on the complicated side)
for the year 2001
28
Admissions AIN102 Module 255
Queries using Queries Result
Admissions AIN102 Module 256
AIN102
Access Query Design
Part 3 – Unions, Action Queries
D. H. D’Urso and Associates
949-489-1472
http://www.dhdursoassociates.com
29
Admissions AIN102 Module 257
Special Queries
 Most are “Action Queries”
 Reached through Query pull-down menu
Admissions AIN102 Module 258
Special Queries
 Special action queries have distinct symbols
30
Admissions AIN102 Module 259
Admissions Database
Diagram of the database for reference in part 3
Admissions AIN102 Module 260
Data Modification Queries
SQL Action Query
INSERT Append
UPDATE Update
DELETE Delete
SELECT…INTO Maketable
31
Admissions AIN102 Module 261
Creating Action Queries
 First set up the select query based on the
table you are selecting from
 Test select query
 Then convert to action query
 When you run an action query there is no
result displayed – must look at the
affected table to see the result
Admissions AIN102 Module 262
Select Into…Maketable
 Creates a new table “on the fly”
32
Admissions AIN102 Module 263
Select Into…Maketable
New table
Existing table
Make Table
Admissions AIN102 Module 264
Archived Labor History
33
Admissions AIN102 Module 265
Delete SQL
 Deletes one or more rows
Basic Syntax:
DELETE FROM table-name
WHERE filter-criteria
Admissions AIN102 Module 266
Delete
Example:
Delete all
archived
records
newer than
12/31/2001
34
Admissions AIN102 Module 267
Delete SQL
Example: Delete all archived
admissions_history newer than 12/31/01
Admissions AIN102 Module 268
Archive after DELETE
35
Admissions AIN102 Module 269
More complex DELETE with FROM
clause
 Can delete based on matching
records in other tables
 Uses from for criteria instead of
where – uses the matched rows as
an implicit filter condition
 Covered in advanced class
Admissions AIN102 Module 270
Append Query (SQL Insert)
 Adds new rows to an existing table
 Two forms:
– Single Row
– Multi-Row
36
Admissions AIN102 Module 271
Single Row Insert
Basic Syntax:
Insert [into] table-name
Values (value-list)
Admissions AIN102 Module 272
Single Row Insert
Basic Example:
INSERT into xLU_BuildStyle
values(6, “Thick”)
Not really used this way in MS Access. Typical MS
Access use would be Insert…Select as shown in
following slides.
37
Admissions AIN102 Module 273
Append Query (Multi-row insert)
Admissions AIN102 Module 274
Multi-row Insert SQL
Basic Syntax:
INSERT [INTO] table-name
SELECT select-statement
38
Admissions AIN102 Module 275
Multi-row Insert (Append)
Add back archived admissions_history
newer than 12/31/01
Admissions AIN102 Module 276
Append (Insert) Results
39
Admissions AIN102 Module 277
Update
 Updates fields in an existing row
Basic Syntax:
UPDATE table-name
SET field1 = new value, field2 = new value,…
WHERE selection-criteria
Admissions AIN102 Module 278
Update in Query Designer
New value
40
Admissions AIN102 Module 279
Update
 Increase the admission_history copays by 10%
(unrealistic to change history but we don’t want to step on our
good tables)
Admissions AIN102 Module 280
Update Results
New values
Remember: you have to look at the affected table.
No “result” is displayed.
41
Admissions AIN102 Module 281
Unions
 Combines the results of two queries
– Ex: current records and history
 Tables must be union compatible (at least in theory!)
 There is no designer in Access; must be done in SQL view
Admissions AIN102 Module 282
Union Syntax
SELECT column-list
FROM table1
UNION [ALL]
SELECT same-columns
FROM table2
42
Admissions AIN102 Module 283
Union Example
Admissions AIN102 Module 284
Union Result
43
Admissions AIN102 Module 285
End Session 2
End of Class!
Notes
Admissions AIN102 Module 286
44
Notes
Admissions AIN102 Module 287
Notes
Admissions AIN102 Module 288
Accelerated Computer Training for Working Professionals
Orange Coast Database Associates Course (800)355-9855 or http://ocdatabases.itgo.com
Orange Coast
Database Associates
Specializing in Microsoft Office,
Access, SQL, and related technologies
Computer Training, Programming & Consulting
32422 Alipaz St., Suite A-15
San Juan Capistrano, CA
(800)355-9855 (Toll Free) | (949)489-1472 (Direct) | (949)485-6284 (Fax)
http://www.dhdursoassociates.com | sales@dhdursoassociates.com
Accelerated Computer Training

Mais conteúdo relacionado

Destaque

Oracle database 12c 2 day + performance tuning guide
Oracle database 12c 2 day + performance tuning guideOracle database 12c 2 day + performance tuning guide
Oracle database 12c 2 day + performance tuning guidebupbechanhgmail
 
pl/sql online Training|sql online Training | iTeknowledge
pl/sql online Training|sql online Training | iTeknowledgepl/sql online Training|sql online Training | iTeknowledge
pl/sql online Training|sql online Training | iTeknowledgeMasood Khan
 
PL/SQL Code for Sample Projects
PL/SQL Code for Sample ProjectsPL/SQL Code for Sample Projects
PL/SQL Code for Sample Projectsjwjablonski
 
Advanced Database Lecture Notes
Advanced Database Lecture NotesAdvanced Database Lecture Notes
Advanced Database Lecture NotesJasour Obeidat
 
Thom Point of View on Segmentation
Thom Point of View on SegmentationThom Point of View on Segmentation
Thom Point of View on SegmentationPieterDuron
 
SQL212.1 Introduction to SQL using Oracle Module 1
SQL212.1 Introduction to SQL using Oracle Module 1SQL212.1 Introduction to SQL using Oracle Module 1
SQL212.1 Introduction to SQL using Oracle Module 1Dan D'Urso
 
鑄造產業轉型升級與發展-創業懶人包-青年創業及圓夢網
鑄造產業轉型升級與發展-創業懶人包-青年創業及圓夢網鑄造產業轉型升級與發展-創業懶人包-青年創業及圓夢網
鑄造產業轉型升級與發展-創業懶人包-青年創業及圓夢網RICK Lin
 
Presentatie REC 250309
Presentatie REC 250309Presentatie REC 250309
Presentatie REC 250309Tim Rootsaert
 
SQL212 Oracle SQL Manual
SQL212 Oracle SQL ManualSQL212 Oracle SQL Manual
SQL212 Oracle SQL ManualDan D'Urso
 
SQL302 Intermediate SQL Workshop 2
SQL302 Intermediate SQL Workshop 2SQL302 Intermediate SQL Workshop 2
SQL302 Intermediate SQL Workshop 2Dan D'Urso
 
Course Catalog
Course CatalogCourse Catalog
Course CatalogDan D'Urso
 
SQL200.1 Module 1
SQL200.1 Module 1SQL200.1 Module 1
SQL200.1 Module 1Dan D'Urso
 
Microsoft access self joins
Microsoft access self joinsMicrosoft access self joins
Microsoft access self joinsDan D'Urso
 
SQL201W MySQL SQL Manual
SQL201W MySQL SQL ManualSQL201W MySQL SQL Manual
SQL201W MySQL SQL ManualDan D'Urso
 

Destaque (20)

Oracle database 12c 2 day + performance tuning guide
Oracle database 12c 2 day + performance tuning guideOracle database 12c 2 day + performance tuning guide
Oracle database 12c 2 day + performance tuning guide
 
pl/sql online Training|sql online Training | iTeknowledge
pl/sql online Training|sql online Training | iTeknowledgepl/sql online Training|sql online Training | iTeknowledge
pl/sql online Training|sql online Training | iTeknowledge
 
Adbms lab manual
Adbms lab manualAdbms lab manual
Adbms lab manual
 
PL/SQL Code for Sample Projects
PL/SQL Code for Sample ProjectsPL/SQL Code for Sample Projects
PL/SQL Code for Sample Projects
 
Advanced Database Lecture Notes
Advanced Database Lecture NotesAdvanced Database Lecture Notes
Advanced Database Lecture Notes
 
Thom Point of View on Segmentation
Thom Point of View on SegmentationThom Point of View on Segmentation
Thom Point of View on Segmentation
 
SQL212.1 Introduction to SQL using Oracle Module 1
SQL212.1 Introduction to SQL using Oracle Module 1SQL212.1 Introduction to SQL using Oracle Module 1
SQL212.1 Introduction to SQL using Oracle Module 1
 
London
LondonLondon
London
 
鑄造產業轉型升級與發展-創業懶人包-青年創業及圓夢網
鑄造產業轉型升級與發展-創業懶人包-青年創業及圓夢網鑄造產業轉型升級與發展-創業懶人包-青年創業及圓夢網
鑄造產業轉型升級與發展-創業懶人包-青年創業及圓夢網
 
Fi
FiFi
Fi
 
PREMIS FOTOGRAFIA FILOSOFICA
PREMIS FOTOGRAFIA FILOSOFICAPREMIS FOTOGRAFIA FILOSOFICA
PREMIS FOTOGRAFIA FILOSOFICA
 
Farrah bostic 5for5
Farrah bostic 5for5Farrah bostic 5for5
Farrah bostic 5for5
 
Allemand
AllemandAllemand
Allemand
 
Presentatie REC 250309
Presentatie REC 250309Presentatie REC 250309
Presentatie REC 250309
 
SQL212 Oracle SQL Manual
SQL212 Oracle SQL ManualSQL212 Oracle SQL Manual
SQL212 Oracle SQL Manual
 
SQL302 Intermediate SQL Workshop 2
SQL302 Intermediate SQL Workshop 2SQL302 Intermediate SQL Workshop 2
SQL302 Intermediate SQL Workshop 2
 
Course Catalog
Course CatalogCourse Catalog
Course Catalog
 
SQL200.1 Module 1
SQL200.1 Module 1SQL200.1 Module 1
SQL200.1 Module 1
 
Microsoft access self joins
Microsoft access self joinsMicrosoft access self joins
Microsoft access self joins
 
SQL201W MySQL SQL Manual
SQL201W MySQL SQL ManualSQL201W MySQL SQL Manual
SQL201W MySQL SQL Manual
 

Semelhante a AIN102 Microsoft Access Queries

AIN102.1 Microsoft Access Queries Module 1
AIN102.1 Microsoft Access Queries Module 1AIN102.1 Microsoft Access Queries Module 1
AIN102.1 Microsoft Access Queries Module 1Dan D'Urso
 
AIN102.2 Microsoft Access Queries
AIN102.2 Microsoft Access QueriesAIN102.2 Microsoft Access Queries
AIN102.2 Microsoft Access QueriesDan D'Urso
 
Multi-dimensional Clustering A nalysis
Multi-dimensional   Clustering A nalysisMulti-dimensional   Clustering A nalysis
Multi-dimensional Clustering A nalysisMarcosUrdaneta7
 
Oracle 12c Multi Process Multi Threaded
Oracle 12c Multi Process Multi ThreadedOracle 12c Multi Process Multi Threaded
Oracle 12c Multi Process Multi ThreadedMarkus Flechtner
 
Oracle Client Failover - Under The Hood
Oracle Client Failover - Under The HoodOracle Client Failover - Under The Hood
Oracle Client Failover - Under The HoodLudovico Caldara
 
AIN100A Microsoft Access Level 1
AIN100A Microsoft Access Level 1AIN100A Microsoft Access Level 1
AIN100A Microsoft Access Level 1Dan D'Urso
 
Oracle Database Administration Part I covering Both Oracle 11g r2 and 12c r1
Oracle Database Administration Part I covering Both Oracle 11g r2 and 12c r1Oracle Database Administration Part I covering Both Oracle 11g r2 and 12c r1
Oracle Database Administration Part I covering Both Oracle 11g r2 and 12c r1John Boyle
 
Profiling Mondrian MDX Requests in a Production Environment
Profiling Mondrian MDX Requests in a Production EnvironmentProfiling Mondrian MDX Requests in a Production Environment
Profiling Mondrian MDX Requests in a Production EnvironmentRaimonds Simanovskis
 
Advanced NDISTest options
Advanced NDISTest optionsAdvanced NDISTest options
Advanced NDISTest optionsYan Vugenfirer
 
Creating Web Applications with IDMS, COBOL and ADSO
Creating Web Applications with IDMS, COBOL and ADSOCreating Web Applications with IDMS, COBOL and ADSO
Creating Web Applications with IDMS, COBOL and ADSOMargaret Sliming
 
Femap API Ideas.pdf
Femap API Ideas.pdfFemap API Ideas.pdf
Femap API Ideas.pdfssuser0aadda
 
MySQL para Desenvolvedores de Games
MySQL para Desenvolvedores de GamesMySQL para Desenvolvedores de Games
MySQL para Desenvolvedores de GamesMySQL Brasil
 
YASEEN EDA VALAPPIL
YASEEN EDA VALAPPILYASEEN EDA VALAPPIL
YASEEN EDA VALAPPILYASEEN EV
 
NETCONF & YANG Enablement of Network Devices
NETCONF & YANG Enablement of Network DevicesNETCONF & YANG Enablement of Network Devices
NETCONF & YANG Enablement of Network DevicesCisco DevNet
 
Oracle Database: Checklist Connection Issues
Oracle Database: Checklist Connection IssuesOracle Database: Checklist Connection Issues
Oracle Database: Checklist Connection IssuesMarkus Flechtner
 
Sangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolestSangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolestConnor McDonald
 
Creating Web Applications with IDMS, COBOL and ADSO
Creating Web Applications with IDMS, COBOL and ADSOCreating Web Applications with IDMS, COBOL and ADSO
Creating Web Applications with IDMS, COBOL and ADSOMargaret Sliming
 
Oracle - Checklist for performance issues
Oracle - Checklist for performance issuesOracle - Checklist for performance issues
Oracle - Checklist for performance issuesMarkus Flechtner
 
Oracle zdm Migrate Amazon RDS Oracle to Oracle Autonomous 2021 Kamalesh Ramas...
Oracle zdm Migrate Amazon RDS Oracle to Oracle Autonomous 2021 Kamalesh Ramas...Oracle zdm Migrate Amazon RDS Oracle to Oracle Autonomous 2021 Kamalesh Ramas...
Oracle zdm Migrate Amazon RDS Oracle to Oracle Autonomous 2021 Kamalesh Ramas...Kamalesh Ramasamy
 

Semelhante a AIN102 Microsoft Access Queries (20)

AIN102.1 Microsoft Access Queries Module 1
AIN102.1 Microsoft Access Queries Module 1AIN102.1 Microsoft Access Queries Module 1
AIN102.1 Microsoft Access Queries Module 1
 
AIN102.2 Microsoft Access Queries
AIN102.2 Microsoft Access QueriesAIN102.2 Microsoft Access Queries
AIN102.2 Microsoft Access Queries
 
Multi-dimensional Clustering A nalysis
Multi-dimensional   Clustering A nalysisMulti-dimensional   Clustering A nalysis
Multi-dimensional Clustering A nalysis
 
Oracle 12c Multi Process Multi Threaded
Oracle 12c Multi Process Multi ThreadedOracle 12c Multi Process Multi Threaded
Oracle 12c Multi Process Multi Threaded
 
AIN100
AIN100AIN100
AIN100
 
Oracle Client Failover - Under The Hood
Oracle Client Failover - Under The HoodOracle Client Failover - Under The Hood
Oracle Client Failover - Under The Hood
 
AIN100A Microsoft Access Level 1
AIN100A Microsoft Access Level 1AIN100A Microsoft Access Level 1
AIN100A Microsoft Access Level 1
 
Oracle Database Administration Part I covering Both Oracle 11g r2 and 12c r1
Oracle Database Administration Part I covering Both Oracle 11g r2 and 12c r1Oracle Database Administration Part I covering Both Oracle 11g r2 and 12c r1
Oracle Database Administration Part I covering Both Oracle 11g r2 and 12c r1
 
Profiling Mondrian MDX Requests in a Production Environment
Profiling Mondrian MDX Requests in a Production EnvironmentProfiling Mondrian MDX Requests in a Production Environment
Profiling Mondrian MDX Requests in a Production Environment
 
Advanced NDISTest options
Advanced NDISTest optionsAdvanced NDISTest options
Advanced NDISTest options
 
Creating Web Applications with IDMS, COBOL and ADSO
Creating Web Applications with IDMS, COBOL and ADSOCreating Web Applications with IDMS, COBOL and ADSO
Creating Web Applications with IDMS, COBOL and ADSO
 
Femap API Ideas.pdf
Femap API Ideas.pdfFemap API Ideas.pdf
Femap API Ideas.pdf
 
MySQL para Desenvolvedores de Games
MySQL para Desenvolvedores de GamesMySQL para Desenvolvedores de Games
MySQL para Desenvolvedores de Games
 
YASEEN EDA VALAPPIL
YASEEN EDA VALAPPILYASEEN EDA VALAPPIL
YASEEN EDA VALAPPIL
 
NETCONF & YANG Enablement of Network Devices
NETCONF & YANG Enablement of Network DevicesNETCONF & YANG Enablement of Network Devices
NETCONF & YANG Enablement of Network Devices
 
Oracle Database: Checklist Connection Issues
Oracle Database: Checklist Connection IssuesOracle Database: Checklist Connection Issues
Oracle Database: Checklist Connection Issues
 
Sangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolestSangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolest
 
Creating Web Applications with IDMS, COBOL and ADSO
Creating Web Applications with IDMS, COBOL and ADSOCreating Web Applications with IDMS, COBOL and ADSO
Creating Web Applications with IDMS, COBOL and ADSO
 
Oracle - Checklist for performance issues
Oracle - Checklist for performance issuesOracle - Checklist for performance issues
Oracle - Checklist for performance issues
 
Oracle zdm Migrate Amazon RDS Oracle to Oracle Autonomous 2021 Kamalesh Ramas...
Oracle zdm Migrate Amazon RDS Oracle to Oracle Autonomous 2021 Kamalesh Ramas...Oracle zdm Migrate Amazon RDS Oracle to Oracle Autonomous 2021 Kamalesh Ramas...
Oracle zdm Migrate Amazon RDS Oracle to Oracle Autonomous 2021 Kamalesh Ramas...
 

Mais de Dan D'Urso

SQL201S Accelerated Introduction to MySQL Queries
SQL201S Accelerated Introduction to MySQL QueriesSQL201S Accelerated Introduction to MySQL Queries
SQL201S Accelerated Introduction to MySQL QueriesDan D'Urso
 
LCD201d Database Diagramming with Lucidchart
LCD201d Database Diagramming with LucidchartLCD201d Database Diagramming with Lucidchart
LCD201d Database Diagramming with LucidchartDan D'Urso
 
Database Normalization
Database NormalizationDatabase Normalization
Database NormalizationDan D'Urso
 
VIS201d Visio Database Diagramming
VIS201d Visio Database DiagrammingVIS201d Visio Database Diagramming
VIS201d Visio Database DiagrammingDan D'Urso
 
PRJ101a Project 2013 Accelerated
PRJ101a Project 2013 AcceleratedPRJ101a Project 2013 Accelerated
PRJ101a Project 2013 AcceleratedDan D'Urso
 
PRJ101xl Project Libre Basic Training
PRJ101xl Project Libre Basic TrainingPRJ101xl Project Libre Basic Training
PRJ101xl Project Libre Basic TrainingDan D'Urso
 
Introduction to coding using Python
Introduction to coding using PythonIntroduction to coding using Python
Introduction to coding using PythonDan D'Urso
 
Stem conference
Stem conferenceStem conference
Stem conferenceDan D'Urso
 
SQL302 Intermediate SQL Workshop 3
SQL302 Intermediate SQL Workshop 3SQL302 Intermediate SQL Workshop 3
SQL302 Intermediate SQL Workshop 3Dan D'Urso
 
Course Catalog
Course CatalogCourse Catalog
Course CatalogDan D'Urso
 
SQL302 Intermediate SQL Workshop 1
SQL302 Intermediate SQL Workshop 1SQL302 Intermediate SQL Workshop 1
SQL302 Intermediate SQL Workshop 1Dan D'Urso
 
SQL206 SQL Median
SQL206 SQL MedianSQL206 SQL Median
SQL206 SQL MedianDan D'Urso
 
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3Dan D'Urso
 
SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2
SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2
SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2Dan D'Urso
 
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1Dan D'Urso
 
SQL202 SQL Server SQL Manual
SQL202 SQL Server SQL ManualSQL202 SQL Server SQL Manual
SQL202 SQL Server SQL ManualDan D'Urso
 
AIN102S Access string function sample queries
AIN102S Access string function sample queriesAIN102S Access string function sample queries
AIN102S Access string function sample queriesDan D'Urso
 
AMP110 Microsoft Access Macros
AMP110 Microsoft Access MacrosAMP110 Microsoft Access Macros
AMP110 Microsoft Access MacrosDan D'Urso
 

Mais de Dan D'Urso (18)

SQL201S Accelerated Introduction to MySQL Queries
SQL201S Accelerated Introduction to MySQL QueriesSQL201S Accelerated Introduction to MySQL Queries
SQL201S Accelerated Introduction to MySQL Queries
 
LCD201d Database Diagramming with Lucidchart
LCD201d Database Diagramming with LucidchartLCD201d Database Diagramming with Lucidchart
LCD201d Database Diagramming with Lucidchart
 
Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
 
VIS201d Visio Database Diagramming
VIS201d Visio Database DiagrammingVIS201d Visio Database Diagramming
VIS201d Visio Database Diagramming
 
PRJ101a Project 2013 Accelerated
PRJ101a Project 2013 AcceleratedPRJ101a Project 2013 Accelerated
PRJ101a Project 2013 Accelerated
 
PRJ101xl Project Libre Basic Training
PRJ101xl Project Libre Basic TrainingPRJ101xl Project Libre Basic Training
PRJ101xl Project Libre Basic Training
 
Introduction to coding using Python
Introduction to coding using PythonIntroduction to coding using Python
Introduction to coding using Python
 
Stem conference
Stem conferenceStem conference
Stem conference
 
SQL302 Intermediate SQL Workshop 3
SQL302 Intermediate SQL Workshop 3SQL302 Intermediate SQL Workshop 3
SQL302 Intermediate SQL Workshop 3
 
Course Catalog
Course CatalogCourse Catalog
Course Catalog
 
SQL302 Intermediate SQL Workshop 1
SQL302 Intermediate SQL Workshop 1SQL302 Intermediate SQL Workshop 1
SQL302 Intermediate SQL Workshop 1
 
SQL206 SQL Median
SQL206 SQL MedianSQL206 SQL Median
SQL206 SQL Median
 
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
 
SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2
SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2
SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2
 
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
 
SQL202 SQL Server SQL Manual
SQL202 SQL Server SQL ManualSQL202 SQL Server SQL Manual
SQL202 SQL Server SQL Manual
 
AIN102S Access string function sample queries
AIN102S Access string function sample queriesAIN102S Access string function sample queries
AIN102S Access string function sample queries
 
AMP110 Microsoft Access Macros
AMP110 Microsoft Access MacrosAMP110 Microsoft Access Macros
AMP110 Microsoft Access Macros
 

Último

Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 

Último (20)

Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 

AIN102 Microsoft Access Queries

  • 1. Accelerated Computer Training for Working Professionals Admissions Case Orange Coast Database Associates Course (800)355-9855 or http://ocdatabases.itgo.com Orange Coast Database Associates Specializing in Microsoft Office, Access, SQL, and related technologies Classes custom designed forWorking Professionals http://www.dhdursoassociates.com San Juan Capistrano, CA (800)355-9855 AIN102 Microsoft Access Queries
  • 2. Admissions AIN1021 AIN102 – Access Query Design Introduction to Access Queries for experienced Windows users P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com AdmissionsAIN1022 AIN102 Contact Information P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com slides.1@dhdursoassociates.com Copyright 2001-20011 All rights reserved.
  • 3. AIN102 Notes  This course is based on an earlier course, SQL200A, which was focused on using SQL in the Access environment. As such the screenshots still reflect SQL view as well the Query Designer view. This is actually a plus. AdmissionsAIN1023 AdmissionsAIN1024  Introduction (s)  Facilities  Course Packet (May vary by course or class) – Student questionnaire in front – Collaterals (Map, Catalog, Etc.) – PowerPoint handouts for all sessions – Evaluation form in back – Training Certificate AIN102 – Access Query Design
  • 4. AdmissionsAIN1025 Orange Coast Database Associates  Loose association of local University instructors and IT Professionals.  Started in 2004  Training – Open Enrollment (public classes in San Juan Capistrano using standardized material) – On-site (custom classes for groups) – Private desk side training for individuals  Consulting & Programming (incl. offshore) AdmissionsAIN1026
  • 5. AdmissionsAIN1027  Quick pace for experienced windows users  Assumes some prior knowledge of Access  End-user, not programmer, oriented  Somewhat structured towards personal use for analysis and reporting AIN102 – Access Query Design AdmissionsAIN1028  Select Queries – Filter Criteria – Calculations – Joins – Grouping  Action Queries – Maketable – Append – Update – Delete  Union Course Topics: AIN102 – Access Query Design
  • 6. AdmissionsAIN1029 Approach: SQL View Used in code; but helpful in understanding what a query does Query Designer Use to construct queries Access has many ways to accomplish tasks. Queries can be constructed using SQL View or the Query Designer. This course focuses on the latter. AIN102 – Access Query Design AdmissionsAIN10210  2 Sessions  Lecture  Demo  Extensive student “hands-on”  Exercises are cumulative – later examples build on objects created earlier Course Format: AIN102 – Access Query Design
  • 7. AIN102 Resources  Manuals can be downloaded from SlideShare.  Slides can be viewed on SlideShare… http://www.slideshare.net/OCDatabases AdmissionsAIN10211 AdmissionsAIN10212  Session 1 – access-qdes-s1-ad.ppt  Session 2 – access-qdes-s2-ad.ppt Course Schedule (3 hour sessions): AIN102 – Access Query Design
  • 8. 1 AIN102 Access Query Design Orange Coast Database Associates, Inc. 949-489-1472 http://www.dhdursoassociates.com AIN102 Access Query Design Module 1 – Relational Database Background, Basic Single Table Retrieval Operations
  • 9. 2 AIN102 Module 13 Admissions AIN102 Module 13 AIN102  Session 1 – Review of Relational Databases and Single Table Retrieval, Functions and Operators  Session 2 – Multi-table retrieval, Subqueries, Unions, Action Queries, Indexes AIN102 Module 14 Admissions AIN102 Module 14 AIN102  Lecture/discussion with demonstrations – Mostly practical, but a dose of “theory”  Assumes some familiarity with MS Access  Hands-on  Exercises (Mostly cumulative)  About 3-4 hours per module  Frequent breaks
  • 10. 3 AIN102 Module 15 Admissions AIN102 Module 15 Module 1  Concepts – Relational databases – SQL – Access Query Designer  SELECT Query – Basic – Filter criteria – Complex criteria • Field Operations • Functions • Operators • Calculated fields • Concatenation AIN102 Module 16 Admissions AIN102 Module 16 Microsoft Access Query Design  Course focus is Microsoft Access Query Design  Queries are widely used for: – Database administration – Enterprise application development – Data driven web sites – Retrieving and modifying data in MS Access databases  A foundation skill for eBusiness and almost all major business applications that use relational databases
  • 11. 4 AIN102 Module 17 Admissions AIN102 Module 17 Access Query Design and SQL  Class database will be MS Access – the SQL engine Access uses is called JET  A basic knowledge of Access is assumed  Focus of this class will be on the query designer, with SQL used from time-to-time to explain concepts AIN102 Module 18 Admissions AIN102 Module 18 Relational Database Basics  Storage  Databases  Tables  Rows  Columns  Indexes  Views  SQL interface
  • 12. 5 AIN102 Module 19 Admissions AIN102 Module 19 Storage  In Access one file with extension mdb. I.e mydatabase.mdb.  Database splitter can be used to split it into two parts – a front end and a back end.  Interface to physical storage via the “JET” database engine. This is the behind-the scenes-workhorse. AIN102 Module 110 Admissions AIN102 Module 110 Databases  In the Access world refers to all objects stored in the mdb. – Tables – Queries – From – Reports – Macros – Code modules
  • 13. 6 AIN102 Module 111 Admissions AIN102 Module 111 Relational Database Table AIN102 Module 112 Admissions AIN102 Module 112 Sample Access Database
  • 14. 7 AIN102 Module 113 Admissions AIN102 Module 113 Database Relationships AIN102 Module 114 Admissions AIN102 Module 114 Approaching Query Design  Try to build queries a step at a time  Save existing queries that are working as you like; modify them with a new name when building a modified query  Try looking at the generated SQL code from time-to-time
  • 15. 8 AIN102 Module 115 Admissions AIN102 Module 115 Query Types  Select  Action – Update – Delete – Insert – Maketable  Special use queries – Data Definition Language (DDL) – Union – SQL pass-through AIN102 Module 116 Admissions AIN102 Module 116 DDL  Data definition language (DDL) to create and modify tables, etc. – Create, alter, drop, etc. – Must be “hand-coded” in Access – But can be useful for database administration  Done in MS Access via SQL Specific Queries – Will not be covered in the course
  • 16. 9 AIN102 Module 117 Admissions AIN102 Module 117 MS Access DDL Queries AIN102 Module 118 Admissions AIN102 Module 118 DCL  Data Control Language (DCL) to control user rights, etc. – Grant – Revoke – Constraints  Used primarily in enterprise databases  Can be done in Access but not covered in this course
  • 17. 10 AIN102 Module 119 Admissions AIN102 Module 119 DML  Data Manipulation Language (DML) – Select Query – Append Query – Update Query – Delete Query – Maketable Query (a special type of Select) – Union Query (really combined Selects)  MS Access Query Designer will create these statements “behind the scenes” AIN102 Module 120 Admissions AIN102 Module 120 MS Access Action Queries
  • 18. 11 AIN102 Module 121 Admissions AIN102 Module 121 Other Access Queries  Crosstab  Pass Through – used to pass an SQL statement directly to a back end database w/out processing by Access AIN102 Module 122 Admissions AIN102 Module 122 Sample Database  Before we continue…  Load the sample database if you haven’t already
  • 19. 12 AIN102 Module 123 Query Designer Admissions AIN102 Module 123 Right click anywhere for SQL View Double click or drag to add a field Double click to add a table AIN102 Module 124 Admissions AIN102 Module 124 SELECT Queries Basic Syntax: Select column-list or * From table-list * Means all columns
  • 20. 13 AIN102 Module 125 Admissions AIN102 Module 125 MS Access SELECT Query Drag and Drop or double click AIN102 Module 126 Admissions AIN102 Module 126 MS Access SELECT SQL
  • 21. 14 AIN102 Module 127 Admissions AIN102 Module 127 Simple Select Query Results AIN102 Module 128 Admissions AIN102 Module 128 SELECT w/ Where Filters retrieved rows Syntax: SELECT column-list FROM table-list WHERE selection-criteria
  • 22. 15 Admissions AIN102 Module 129 Comparison Operators  < less than  > greater than  <= less than or equal  >= greater than or equal  = equal  <> not equal AIN102 Module 130 Admissions AIN102 Module 130 SELECT w/ WHERE
  • 23. 16 AIN102 Module 131 Admissions AIN102 Module 131 SELECT w/ WHERE AIN102 Module 132 Admissions AIN102 Module 132 SELECT w/ WHERE Results
  • 24. 17 AIN102 Module 133 Admissions AIN102 Module 133 Complex Filters Follows normal boolean logic Select PatID, LastName, etc… From patients Where (LastName = “Thomas” or birthdate < #1/1/95#) and city = “Corona”) AIN102 Module 134 Admissions AIN102 Module 134 Complex Filter AND
  • 25. 18 AIN102 Module 135 Admissions AIN102 Module 135 Select w/ Complex Where AIN102 Module 136 Admissions AIN102 Module 136 Complex Filter Results
  • 26. 19 AIN102 Module 137 Admissions AIN102 Module 137 Special Operators  LIKE  IN  BETWEEN  IS NULL AIN102 Module 138 Admissions AIN102 Module 138 Like (“Wild Card Matches”)  Where customer_last_name like “Jo*” – *= string of characters  Where customer_last_name like “Jo?” – ? = exactly one character Access actually allows more sophisticated Unix style search patterns as well – see help.
  • 27. 20 AIN102 Module 139 Admissions AIN102 Module 139 LIKE Names ending in “S” AIN102 Module 140 Admissions AIN102 Module 140 LIKE Names ending in “S”
  • 28. 21 AIN102 Module 141 Admissions AIN102 Module 141 LIKE Results AIN102 Module 142 Admissions AIN102 Module 142 IS NULL Select columnns From clients Where zip IS NULL SQL (including JET) uses three valued logic. Must use IS NULL to test for unknowns. A null is NOT the same as blank or empty.
  • 29. 22 AIN102 Module 143 Admissions AIN102 Module 143 IS NULL AIN102 Module 144 Admissions AIN102 Module 144 IS NULL
  • 30. 23 AIN102 Module 145 Admissions AIN102 Module 145 IS NULL Results OK. Now try finding all patients with a blank address. Was the above row retrieved? Why or why not? AIN102 Module 146 Admissions AIN102 Module 146 IN Select * From patients Where lastname IN (“Smith”, “Thomas”, “Juarez”) Note: what is inside parentheses is a list. Later we will replace the list with a subquery which generates the list items.
  • 31. 24 AIN102 Module 147 Admissions AIN102 Module 147 IN AIN102 Module 148 Admissions AIN102 Module 148 IN List of values
  • 32. 25 AIN102 Module 149 Admissions AIN102 Module 149 SELECT w/in IN Results AIN102 Module 150 Admissions AIN102 Module 150 BETWEEN SELECT * FROM admissions WHERE admit_date BETWEEN #10/1/2001# and #12/31/2001# Note: between is inclusive
  • 33. 26 AIN102 Module 151 Admissions AIN102 Module 151 BETWEEN AIN102 Module 152 Admissions AIN102 Module 152 BETWEEN Results
  • 34. 27 AIN102 Module 153 Admissions AIN102 Module 153 Removing Duplicates SELECT DISTINCT PatNo FROM admissions List once each employee who has a labor ticket Removes duplicate rows from result set AIN102 Module 154 Admissions AIN102 Module 154 DISTINCT
  • 35. 28 AIN102 Module 155 Admissions AIN102 Module 155 Distinct Results W/out Distinct With Distinct AIN102 Module 156 Admissions AIN102 Module 156 Sorting – ORDER BY DESC will sort in descending order Basic syntax: SELECT column list FROM table list WHERE selection criteria ORDER BY column list [DESC]
  • 36. 29 AIN102 Module 157 Admissions AIN102 Module 157 Sorting – ORDER BY Select * From patients Where state in(“CA”, “OR”, “WA”) Order by birthdate desc Example: List patients in Pacific Coast sorted by youngest to oldest AIN102 Module 158 Admissions AIN102 Module 158 Sorting – ORDER BY Note: modify the “select_in” query
  • 37. 30 AIN102 Module 159 Admissions AIN102 Module 159 Sorting – ORDER BY AIN102 Module 160 Admissions AIN102 Module 160 Sorting – Results
  • 38. 31 AIN102 Module 161 Admissions AIN102 Module 161 Query/SQL Exercises  List all patient numbers, etc. for patients who co- paid more than $20; sort by co-pay amount, largest first  List diagnostics that contain b, d, or q in the diagnostic code  List the patient id’s for admissions in the fall (Sep, Oct, Nov) of 2001 and 2002 AIN102 Module 162 Admissions AIN102 Module 162 Calculated Fields Example: Select a + b as result Syntax: SELECT expression AS new column name Result is a “column alias”
  • 39. 32 AIN102 Module 163 Admissions AIN102 Module 163 Calculated Fields New column name Follow name with “:” AIN102 Module 164 Admissions AIN102 Module 164 Calculated Fields
  • 40. 33 AIN102 Module 165 Admissions AIN102 Module 165 Calculated Fields - Results AIN102 Module 166 Admissions AIN102 Module 166 Concatenation  “Adds” two character fields using “&” symbol  Useful for formatting names, addresses, etc.  Example: – Select firstname & “ “ & lastname as fullname
  • 41. 34 AIN102 Module 167 Admissions AIN102 Module 167 Concatenation Sort, but don’t show AIN102 Module 168 Admissions AIN102 Module 168 Concatenation
  • 42. 35 AIN102 Module 169 Admissions AIN102 Module 169 Concatenation Single column with full name, sorted by last name Tip: handy for reports AIN102 Module 170 Admissions AIN102 Module 170 SQL Exercises  List all the patients with a “fullname” field; sorted by last name. Add a calculated field which shows their loaded copay (copay *1.5). Show the fullname, but not the individual names.
  • 43. 36 AIN102 Module 171 Admissions AIN102 Module 171 End Session 1 Next session: multi-table operations, subqueries, unions, action queries, indexes
  • 44. 1 Admissions AIN102 Module 21 AIN102 Access Query Design Module 2 P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com Admissions AIN102 Module 22 Module 2  Part 1 – Miscellaneous Functions  Strings  Dates – Summaries (Grouping)  Part 2 – Joins, subqueries – Inner join – Outer joins – Subqueries  Multi-valued  Single-valued • Part 3 – Unions, Action Queries, Indexes • Unions • Maketable Query • Delete • Append • Update • Indexes
  • 45. 2 Admissions AIN102 Module 23 String Manipulation  Trim  Substring  UCase, LCase  Left, Right  See help for others Admissions AIN102 Module 24 String Manipulation
  • 46. 3 Admissions AIN102 Module 25 String Manipulation Admissions AIN102 Module 26 String Example
  • 47. 4 Admissions AIN102 Module 27 Date Functions  Numerous date functions – DatePart – DateDiff – DateAdd – Etc.  Often used: – Year – Month  Ex: where year(birthdate) = 1999 Admissions AIN102 Module 28 DateDiff  How long did patients stay in weeks?
  • 48. 5 Admissions AIN102 Module 29 DateDiff results Note: Access has many date functions with many options. Admissions AIN102 Module 210 Ex: Date Function – Month()
  • 49. 6 Admissions AIN102 Module 211 Ex: Date Function – Month() Admissions AIN102 Module 212 Result of Month Function
  • 50. 7 Admissions AIN102 Module 213 Summary Functions  Count  Sum  Min  Max  Avg  Often used in conjunction with grouping Admissions AIN102 Module 214 Summary Functions in Access Click the sum symbol Adds a total row
  • 51. 8 Admissions AIN102 Module 215 Summary Functions - Syntax Basic syntax: SELECT function(column) FROM table WHERE filter-condition GROUP BY column-list HAVING group-filter Group by all columns to left of one(s) you to want aggregate Admissions AIN102 Module 216 Simple Column Summaries This query counts patient admissions In the year 2001
  • 52. 9 Admissions AIN102 Module 217 Simple Column Summaries Admissions AIN102 Module 218 Simple Record Count
  • 53. 10 Admissions AIN102 Module 219 “The COUNTS”  Count(*) – counts records  Count(fieldname) – counts non–null occurrences of field name  Count (distinct fieldname) – counts distinct occurrences, but not supported in access Admissions AIN102 Module 220 Grouping  Organizes results into summary rows, one per group  Groups can have sub groups which have sub groups and so on….
  • 54. 11 Admissions AIN102 Module 221 GROUP BY in Query Designer Admissions AIN102 Module 222 GROUP BY Problem Not an aggregate or group You will see this error a lot. Not to worry. It happens to everyone!
  • 55. 12 Admissions AIN102 Module 223 Group By Results Admissions AIN102 Module 224 Having  Restricts the groups returned  Operates on the groups after they have been formed HAVING (((Admissions.Diag_Code) Like "a*"))
  • 56. 13 Admissions AIN102 Module 225 Having – SQL View  Restricts the groups returned  Operates on the groups after they have been formed Admissions AIN102 Module 226 HAVING
  • 57. 14 Admissions AIN102 Module 227 HAVING Results Admissions AIN102 Module 228 AIN102 Access Query Design Part 2 – Joins, Subqueries
  • 58. 15 Admissions AIN102 Module 229 Database Design Diagram of the database for reference in joins Admissions AIN102 Module 230 Joins  Used to combine columns from more than one table  Several types – Inner – Outer  Left  Right – Others (not covered)  Full Outer (Not supported in Access)  Cross  Self  Non equal
  • 59. 16 Admissions AIN102 Module 231 Inner Join  Pairs each row from first table with corresponding row from second table over the “join column” or “linking column”  The result only contains rows where there is a match over the join column in both tables  The default join in most databases Admissions AIN102 Module 232 Inner Join Syntax Basic SQL 92 Syntax: SELECT column-list FROM table1 [AS alias] INNER JOIN table2 [AS alias] ON join-condition
  • 60. 17 Admissions AIN102 Module 233 Table Aliases  Shorthand name for a table  Used in more complex queries Select t.id, s.lname From _traveler as t Inner join xLU_Staff as s On t.staffid = s.staffid Table alias Admissions AIN102 Module 234 Inner Join Basic SQL Example Basic Example: Add patient names to admissions data Two join tables Join condition
  • 61. 18 Admissions AIN102 Module 235 Inner Join Query Design Admissions AIN102 Module 236 Inner Join Results
  • 62. 19 Admissions AIN102 Module 237 Inner Join over Multiple columns  Note that that the join condition can apply to multiple columns if desired  Used with composite keys Select …. From tablea as ta Inner join tableb as tb On ta.key1 = tb.key1 And ta.key2 = tb.key2 Admissions AIN102 Module 238 Joining More than Two Tables  Can join several tables in one select  Try to limit to three or four  Demonstration example
  • 63. 20 Admissions AIN102 Module 239 3 Table Query Results Admissions AIN102 Module 240 More on Aliases  Can be set in Query Designer, too, by right clicking on a table  Useful for debugging top level queries as we shall see later
  • 64. 21 Admissions AIN102 Module 241 Outer Joins  Left – selects all rows from the left or first table, even if no match exists in the other table – Widely used in commercial practice, esp. for reporting  Right – same idea but all rows from right table  Full – all rows from both tables; not supported in Access Admissions AIN102 Module 242 Left Outer Join Basic SQL 92 Syntax: SELECT column-list FROM table1 LEFT JOIN table2 ON join-condition
  • 65. 22 Admissions AIN102 Module 243 Left Outer Join (Right click on relationship to edit) Admissions AIN102 Module 244 Left Outer Join  Modify your prior inner join to use a left join  Save as qryLeft_Admit  Now run both the inner and left joins  What is the difference?
  • 66. 23 Admissions AIN102 Module 245 Left Outer Join Results Admissions AIN102 Module 246 Subqueries  One select statement embedded in another  Can be nested multiple levels deep  In Access query designer can be placed in criteria row or field row
  • 67. 24 Admissions AIN102 Module 247 Multi-valued Subquery  A type of subquery that compares to a list  Ex: find all diagnostic codes with no admissions  Commonly encountered in commercial practice Admissions AIN102 Module 248 Multi-valued Subquery  Place subquery in criteria row
  • 68. 25 Admissions AIN102 Module 249 Multi-valued Subquery Result No one was ever admitted with these diagnoses. Admissions AIN102 Module 250 Single-valued Subquery Subquery that returns a single value Find all admissions with stays greater than the average stay
  • 69. 26 Admissions AIN102 Module 251 Single-valued Subquery Subquery that returns a single value Admissions AIN102 Module 252 Single-valued Subquery Result
  • 70. 27 Admissions AIN102 Module 253 Queries using Queries  Queries can be read just like a table  Some are updateable  Using a query as a source for another query very common in Access – especially for complicated queries  In a “back end” database such as Oracle or SQL Sever you would use a View Admissions AIN102 Module 254 Queries using Queries Filter the prior query ( a little on the complicated side) for the year 2001
  • 71. 28 Admissions AIN102 Module 255 Queries using Queries Result Admissions AIN102 Module 256 AIN102 Access Query Design Part 3 – Unions, Action Queries D. H. D’Urso and Associates 949-489-1472 http://www.dhdursoassociates.com
  • 72. 29 Admissions AIN102 Module 257 Special Queries  Most are “Action Queries”  Reached through Query pull-down menu Admissions AIN102 Module 258 Special Queries  Special action queries have distinct symbols
  • 73. 30 Admissions AIN102 Module 259 Admissions Database Diagram of the database for reference in part 3 Admissions AIN102 Module 260 Data Modification Queries SQL Action Query INSERT Append UPDATE Update DELETE Delete SELECT…INTO Maketable
  • 74. 31 Admissions AIN102 Module 261 Creating Action Queries  First set up the select query based on the table you are selecting from  Test select query  Then convert to action query  When you run an action query there is no result displayed – must look at the affected table to see the result Admissions AIN102 Module 262 Select Into…Maketable  Creates a new table “on the fly”
  • 75. 32 Admissions AIN102 Module 263 Select Into…Maketable New table Existing table Make Table Admissions AIN102 Module 264 Archived Labor History
  • 76. 33 Admissions AIN102 Module 265 Delete SQL  Deletes one or more rows Basic Syntax: DELETE FROM table-name WHERE filter-criteria Admissions AIN102 Module 266 Delete Example: Delete all archived records newer than 12/31/2001
  • 77. 34 Admissions AIN102 Module 267 Delete SQL Example: Delete all archived admissions_history newer than 12/31/01 Admissions AIN102 Module 268 Archive after DELETE
  • 78. 35 Admissions AIN102 Module 269 More complex DELETE with FROM clause  Can delete based on matching records in other tables  Uses from for criteria instead of where – uses the matched rows as an implicit filter condition  Covered in advanced class Admissions AIN102 Module 270 Append Query (SQL Insert)  Adds new rows to an existing table  Two forms: – Single Row – Multi-Row
  • 79. 36 Admissions AIN102 Module 271 Single Row Insert Basic Syntax: Insert [into] table-name Values (value-list) Admissions AIN102 Module 272 Single Row Insert Basic Example: INSERT into xLU_BuildStyle values(6, “Thick”) Not really used this way in MS Access. Typical MS Access use would be Insert…Select as shown in following slides.
  • 80. 37 Admissions AIN102 Module 273 Append Query (Multi-row insert) Admissions AIN102 Module 274 Multi-row Insert SQL Basic Syntax: INSERT [INTO] table-name SELECT select-statement
  • 81. 38 Admissions AIN102 Module 275 Multi-row Insert (Append) Add back archived admissions_history newer than 12/31/01 Admissions AIN102 Module 276 Append (Insert) Results
  • 82. 39 Admissions AIN102 Module 277 Update  Updates fields in an existing row Basic Syntax: UPDATE table-name SET field1 = new value, field2 = new value,… WHERE selection-criteria Admissions AIN102 Module 278 Update in Query Designer New value
  • 83. 40 Admissions AIN102 Module 279 Update  Increase the admission_history copays by 10% (unrealistic to change history but we don’t want to step on our good tables) Admissions AIN102 Module 280 Update Results New values Remember: you have to look at the affected table. No “result” is displayed.
  • 84. 41 Admissions AIN102 Module 281 Unions  Combines the results of two queries – Ex: current records and history  Tables must be union compatible (at least in theory!)  There is no designer in Access; must be done in SQL view Admissions AIN102 Module 282 Union Syntax SELECT column-list FROM table1 UNION [ALL] SELECT same-columns FROM table2
  • 85. 42 Admissions AIN102 Module 283 Union Example Admissions AIN102 Module 284 Union Result
  • 86. 43 Admissions AIN102 Module 285 End Session 2 End of Class! Notes Admissions AIN102 Module 286
  • 87. 44 Notes Admissions AIN102 Module 287 Notes Admissions AIN102 Module 288
  • 88. Accelerated Computer Training for Working Professionals Orange Coast Database Associates Course (800)355-9855 or http://ocdatabases.itgo.com Orange Coast Database Associates Specializing in Microsoft Office, Access, SQL, and related technologies Computer Training, Programming & Consulting 32422 Alipaz St., Suite A-15 San Juan Capistrano, CA (800)355-9855 (Toll Free) | (949)489-1472 (Direct) | (949)485-6284 (Fax) http://www.dhdursoassociates.com | sales@dhdursoassociates.com Accelerated Computer Training