Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
2 views
Queries Notes
Database Notes
Uploaded by
csecclassnrmss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Queries Notes For Later
Download
Save
Save Queries Notes For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
2 views
Queries Notes
Database Notes
Uploaded by
csecclassnrmss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Queries Notes For Later
Carousel Previous
Carousel Next
Save
Save Queries Notes For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 7
Search
Fullscreen
Peron ean @ ‘Computers have important advantages over manual systems since they can work extremely quickly, and automatically, to make calculations and to retrieve and sort data into some useful form. All these functions are known as data processing. Searching Searching a database is reasonably straightforward once ‘you realise that you must tell the program precisely what to search for. You do this by giving clear criteria (conditions) for the search. You might know what you want to find, but the software does not ~ until you tell it. A query (also known asa filter or search) is used to answer a question using the data in a database. The database is searched to find all the records that match a particular condition. A query is the question you ask, such as ‘List the first names of the customers who ordered round labels.’ it is not the results (for example, ‘Ann and Lou). You may make several queries to ask different specific questions. When a query is‘run’it produces as output Simple Query Wizard ables queries [Fable Product ‘valable Feds: << cancel ij 820 Using the Query Wizard 0 slat felcs ina query a list of all the records that match the condition that defined the query. Once you have created a query, you can run it as often as needed. Even the results of the query will be updated if you add more data to the table. When you begin to design your queries, ask yourself © What specific question do I want to ask? + What data (fields) do I need displayed? * What sort order will help me the most? Queries can be as simple or as complex as you like. “To search a database, you must first enter the search, criteria into one or more fields for their tables. Then you instruct the program to find all the records that match the conditions that you have set. For example, to find the products with orders that are less than 50, you would type <50 in the QTY field of the Order table. First Description ary Lou ‘Small Clips 10 Bev Pocket Diary 5 Ann Small Clips 10 ‘which fields do you wantin your query? ‘You can choose from more than one table or query Bl Selected Fes: lot ‘nish8 Databases FB customers who ordered products with quantities of less than 50) Product B prad Description cost Customer Foo Last Fist Description Product Description | QTY ‘small Clips Pocket Diary Wall ‘Small Clips * Record M(t of Fig 82! Creating aque to ist the procs with orders of ess than 50 After executing the query, you may see one or more records that were produced from your search, ‘The comparisons that you can make in queries will depend on which database program you are using Table 85 lists some common operators used. Searching for specific records ‘The word ‘criteria’ in a database means you want to find only certain records and ignore others (the ‘ones that do not meet the criteria conditions). If you want to limit the results of your query, you can set up specific criteria. If a record meets those criteria, it a oor No fiter_| Search is included in the results. Note also in Table 8.5 that the criteria does not include any formatting such as the dollar sign ($) or percentage symbol (9%). Any search using text as the criteria is enclosed in double quotation marks. For example, suppose you wish to find the product with ID P3430. This produces one result: Small Clips costing $2.75. Figure 8.22 illustrates how you place P3430 in the criteria row below the field name where you wish to find the specific records. The other fields can be selected (ticked) to indicate that you wish to see their results as well. IF you only wish to see the product description and the costs, make sure only those two fields are selected.8.5 Searching and sorting Table 8.5 Operators used in searching databases Operator Meaning Example = Equal to *P3122" searches the product ID number field to find all products with that identical product ID > Greater than > 5 searches the cost field to find all products that cpst more than $5.00 Less than ‘<5 searches the cost field to find all products that cost less than $5.00 os Greater than or equal to >= 5 searches the cost field to finds products whose cost is greater than or equal to $5.00 = Less than or equal to <= 5 searches the cost field to find products that cost less than or equal 1055.00 * Asterisk, known as a wild-card character, can “R* or like*R* will find all products whose first character or letter beused to represent one or more characters begins with R, for example Receipt books and Round labels Oesripton of Proaucid a0 x Products costing more than $5 = Product ° Bodud. “ io nea 8 prio re Description cos ‘ . aI , fat (rio Desction ce Description cos * Te oa rele roost] — =. saove a a a ot: 3 on . > a ig 82 Searching fora descotion fo product P3430 ‘ > Also notice that there is only one table selected. If iption Cost the fields you need for the query are found in one Packet Diary 3895 tuble then the other tables should be deleted from the [Receipt Book 3755 query. Otherwise you may find duplicate records in ig 823 Query (find products that cost mare than $5.00 ands sue your result. To delete a table in query design, select the table, right-click and select remove table or select the table and press the Delete key on your keyboard. Figures 8.23 and 8.24 show other examples of how to find products that cost more than $5.00 (Fig 8.23) or those that begin with ‘R’ (Fig 8.24).8 Databases FF cunt x Product oo Description cost Field Table: Sort: Show: crteria: * No fites |Search] Fig 24 Query to fndthe names of products that begin with Rand as result Queries using more than one field ‘You can create more complicated queries by linking together more than one search condition. For example, find the customers who ordered products costing less than $5 in quantities of more than 100. Figure 8.25 shows how in Microsoft Access <5 and >100 are placed on the same criteria row but under their field names. This joins the two queries with the AND operator. Another query finds the customers who ordered products costing less than $5 OR products with quantities of more than 100. Figure 8.26 shows how in Microsoft Access <5 and >100 are placed on two lines labelled as ‘criteria’ and ‘or’ It does not matter which one is entered in the criteria or the OR row once they are not in the same row. This joins the two queries with the OR operator. The result below can be saved as Less than $5 or More than 100. First Description | Cost ‘ary Lou ‘Small Clips 3273 10 ‘Ann ‘Small Clips $275 10 Tou Round Labels $395 500 Ann Round Labels $395 100 Lou Black Pen $1.25 50 Product C Fon vo = |t__a| oem bd 2 PRD ES wma nemo fl om RE Fig 8250 Query find the customers who.rdered products casting less than Sin quantities ofimore than 100 a8.5 Searching and sorting | -P customers who ordre products with quantities of less than 50)\ x Description «| Cost. | any - Round Labels $3.95. +500 * [Recor #11» won| = NoFiter | Search ig 825 rests fom query to find the customers who odered proces costing less than $5 in quonties of more than 100 | tata eto ton 8 ~caoner | [om | Prout so [4 _.| ye 1) 9 mo tat eel] carts me | con |__| cra G le ex ‘Desenption ‘cost ant 1 Cone room cert oar 1 — a = ce - ig 826 Query to ind the customers who oidered products costing less than $508 quanaties ofmore than 100, Notice that in these queries all three tables were used since fields were needed from each table. However, if fields from the Customer and Product tables were needed, the Order table should not be deleted since it is linking these two tables in the database. For example, suppose the Bookshop needed to contact all customers who ordered Black Pens.’The First and Last field names would be selected from the Customer table, while the Product ID (PR-ID) or Description for the Black Pens could be selected from the Product table and not the Order table. ‘The words AND and OR are the only ones that can be used to link two simple conditions together to make a more complicated query:’The difference between using AND or OR to join two conditions is: » AND: Find only records which match doth of the conditions, * OR: Find records that match either or both of the conditions, Reversing queries Sometimes you may want to search for records which do not match a particular criteria. For example, you may want to find all customer orders except those for customer Lou. The keyword NOT is used to do this (Fig 8.27a). et Ds8 Databases (Wh Garo ets ecg Product ‘Customer oar va jt 2] Fm tat Fimo Fest -_ Fat: Te Fig8.27a Qvery:ofind at rer NOT paced by Customer Lou (5 conor oor capi x Deterpton = scp ga a ev Pocket Diary $8.95 on Small Cpe $275 Fe an Rovnd Labels $3.95 100 ier
wn pt [Se Fig 27o Result of ery 0 find al orders NOT placed by Customer Lou Sorting Most databases will let you sort data so that it is displayed in a specified order. To sort a database into an order you must specify: + which field in the database you wish to use to order the records ‘+ whether you want the records in ascending (A to Z) 21 or descending (Z to A) order Al , Sorting records temporarily reorders the database file, Sorting allows you to browse, update, export or print records in a particular order. You can also sort numbers, dates and times in ascending and descending order. Being able to sort records quickly is one of the advantages of using a database, Depending on your version of Microsoft Access, you may have one or more methods of sorting your data. However, the result remains the same. “The following three examples show how your results can be sorted by the last name field in ascending order. OSS Figure 8.28 shows how the sort option in Design view is used to order the data. customer ig 8.28 Design view showing how the lst pamesof the customers can be sened m ascending order Figure 8.29 shows how the Sort and Filter menu Datasheet view is used to sort the data, Fig829Using the Sot and iter meny option in Datosbee! view to sort the dota=) Deiciton =| Cant =| OY $595 3 S75 0 13s 0 5395 soo + srs 10 S195 100 755 100 Fig 830 Using thesort option tothe right ofthe feld name tacxder the dara Questions 1. Select the most suitable options that describe the sorting of data as A to Z: 4 ascending i descending top to bottom iv bottom totop, Use the query template shown in Figure 8.31 to answer questions 2 and 3: 2. You wish to lst the names of the products that cost under $3.00. ‘a Write one or more tables that would be used in the query. 8.5 Searching and sorting Figure 8.30 uses the Sort option in the field names to order the data. All these methods will give the following results. Last First [Description [Cost [QTY King Bev | Pocket Diary $895 5 Tedd Tou __| Small Clips 5275 10 Tedd Tou [Round Labels 33:95 | 500 Tedd Lou | Black Pen 12550 Wall ‘Aan | Small Clips s275[ 10 Wall ‘Ann __| Round Labels $3.95| 100 Yod Ed__| Receipt Book 3755| 100 b List the field names that would be used in the query, € Write the field name and the criteria for the query. d_ How would the criteria change ifthe query was changed to list the products that cost $3.00 or fess? 3. Youwish to list the names of the products that are on discount. a Write one or more tables that would be used in the query. List the field names that would be used in the query € Write the field name and the criteria for the query. Coomer ‘onter vo0 12] 20 us Imo ome Desergin x Fig8.31 Query template
You might also like
Access 5 PDF
PDF
No ratings yet
Access 5 PDF
11 pages
Microsoft Access 2000
PDF
No ratings yet
Microsoft Access 2000
17 pages
Queries
PDF
No ratings yet
Queries
28 pages
Tables: Store Your Data in Your Database Queries: Ask Questions About Information
PDF
No ratings yet
Tables: Store Your Data in Your Database Queries: Ask Questions About Information
88 pages
7 Queries
PDF
No ratings yet
7 Queries
102 pages
Access For Microsoft 365 Access 2019 Access 2016 Access 2013 Access 2010 Access 2007
PDF
No ratings yet
Access For Microsoft 365 Access 2019 Access 2016 Access 2013 Access 2010 Access 2007
26 pages
revieweerrr
PDF
No ratings yet
revieweerrr
8 pages
Access-2016 SortFilter L5
PDF
No ratings yet
Access-2016 SortFilter L5
9 pages
Lesson 8 Running Queries and Reports - Designing A Query
PDF
No ratings yet
Lesson 8 Running Queries and Reports - Designing A Query
18 pages
SQL - Copy2
PDF
No ratings yet
SQL - Copy2
10 pages
SQL For Developers - Basic Data Retrieval - CodeProject
PDF
No ratings yet
SQL For Developers - Basic Data Retrieval - CodeProject
8 pages
lesson3 (1)
PDF
No ratings yet
lesson3 (1)
66 pages
Practical 09
PDF
No ratings yet
Practical 09
33 pages
SQL Sarans
PDF
No ratings yet
SQL Sarans
17 pages
__xid-32778727_1
PDF
No ratings yet
__xid-32778727_1
55 pages
Part 2 - Sorting and Filtering
PDF
No ratings yet
Part 2 - Sorting and Filtering
26 pages
SQL by Rohan
PDF
No ratings yet
SQL by Rohan
13 pages
SU2 Database File Handling2 Slides
PDF
No ratings yet
SU2 Database File Handling2 Slides
12 pages
LAB 04 Basic Queries (Part 2) : IN Operator
PDF
No ratings yet
LAB 04 Basic Queries (Part 2) : IN Operator
14 pages
Lecture 5-Access
PDF
No ratings yet
Lecture 5-Access
80 pages
ITDBS Lab Session 03
PDF
No ratings yet
ITDBS Lab Session 03
8 pages
SQLNotes
PDF
No ratings yet
SQLNotes
223 pages
Chapter 6 - Introduction To SQL
PDF
No ratings yet
Chapter 6 - Introduction To SQL
6 pages
Advanced Databases Practical Lecture 1
PDF
No ratings yet
Advanced Databases Practical Lecture 1
99 pages
SQL
PDF
No ratings yet
SQL
33 pages
CF - Lab12-Introduction To MS ACCESS
PDF
No ratings yet
CF - Lab12-Introduction To MS ACCESS
14 pages
SQL Cheatsheet
PDF
No ratings yet
SQL Cheatsheet
13 pages
DATA MANIPULATION Year 10
PDF
No ratings yet
DATA MANIPULATION Year 10
78 pages
Week+2SQL
PDF
No ratings yet
Week+2SQL
7 pages
Jeffrey A. Hoffer, V. Ramesh, Heikki Topi: Modern Database Management 12 Edition
PDF
No ratings yet
Jeffrey A. Hoffer, V. Ramesh, Heikki Topi: Modern Database Management 12 Edition
32 pages
Lesson 7 Sorting and Filtering Records
PDF
No ratings yet
Lesson 7 Sorting and Filtering Records
17 pages
SQL_basicStatements
PDF
No ratings yet
SQL_basicStatements
24 pages
Databases For A Purpose 03
PDF
No ratings yet
Databases For A Purpose 03
124 pages
SME Database Notes
PDF
No ratings yet
SME Database Notes
13 pages
Fourth Lecture
PDF
No ratings yet
Fourth Lecture
9 pages
Access Lec3
PDF
No ratings yet
Access Lec3
72 pages
Lecture 7
PDF
No ratings yet
Lecture 7
7 pages
Query-By-Example (QBE) in MS Access: Presented By: Engr. Lizel Rose Q. Natividad
PDF
No ratings yet
Query-By-Example (QBE) in MS Access: Presented By: Engr. Lizel Rose Q. Natividad
74 pages
Department of Information Technology
PDF
No ratings yet
Department of Information Technology
6 pages
Presentation_-_Where
PDF
No ratings yet
Presentation_-_Where
16 pages
Udacity Challenge Prog - DS With Python - NOTES
PDF
No ratings yet
Udacity Challenge Prog - DS With Python - NOTES
84 pages
W9 Lesson 7 Introduction To MySQL - Presentation
PDF
No ratings yet
W9 Lesson 7 Introduction To MySQL - Presentation
29 pages
Endless SQL Possibilities
PDF
No ratings yet
Endless SQL Possibilities
5 pages
4b836ef3200849e940887c1dd614947f_lec7
PDF
No ratings yet
4b836ef3200849e940887c1dd614947f_lec7
5 pages
Lesson 8 - More Complex Queries
PDF
No ratings yet
Lesson 8 - More Complex Queries
9 pages
1 SQL
PDF
No ratings yet
1 SQL
45 pages
Mysql
PDF
No ratings yet
Mysql
2 pages
Lecture 0 - CS50's Introduction To Databases With SQL
PDF
No ratings yet
Lecture 0 - CS50's Introduction To Databases With SQL
12 pages
Lec4 - SQL ASR
PDF
No ratings yet
Lec4 - SQL ASR
55 pages
MS Access_Queries+1
PDF
No ratings yet
MS Access_Queries+1
9 pages
MS Access Responses
PDF
No ratings yet
MS Access Responses
10 pages
Shelly Cashman Series Microsoft Office 365 and Access 2016 Introductory 1st Edition Pratt Solutions Manual 1
PDF
100% (70)
Shelly Cashman Series Microsoft Office 365 and Access 2016 Introductory 1st Edition Pratt Solutions Manual 1
11 pages
Shelly Cashman Series Microsoft Office 365 and Access 2016 Introductory 1st Edition Pratt Solutions Manual 1
PDF
100% (50)
Shelly Cashman Series Microsoft Office 365 and Access 2016 Introductory 1st Edition Pratt Solutions Manual 1
36 pages
Shelly Cashman Series Microsoft Office 365 and Access 2016 Intermediate 1st Edition Pratt Solutions Manual 1
PDF
100% (49)
Shelly Cashman Series Microsoft Office 365 and Access 2016 Intermediate 1st Edition Pratt Solutions Manual 1
36 pages
Shelly Cashman Series Microsoft Office 365 and Access 2016 Intermediate 1st Edition Pratt Solutions Manual 1
PDF
100% (68)
Shelly Cashman Series Microsoft Office 365 and Access 2016 Intermediate 1st Edition Pratt Solutions Manual 1
11 pages
manual-testing-120-130
PDF
No ratings yet
manual-testing-120-130
11 pages
LESSON TWO DATABASE
PDF
No ratings yet
LESSON TWO DATABASE
5 pages
Using SQL and Python For Data Analytics
PDF
No ratings yet
Using SQL and Python For Data Analytics
113 pages
SQL Notes
PDF
No ratings yet
SQL Notes
49 pages
Intellectual Property , Copyright and Plagiarism
PDF
No ratings yet
Intellectual Property , Copyright and Plagiarism
4 pages
Presentation Software
PDF
No ratings yet
Presentation Software
6 pages
Envelopes and Labels
PDF
No ratings yet
Envelopes and Labels
3 pages
Literary Documents
PDF
No ratings yet
Literary Documents
6 pages
Display Documents Part2
PDF
No ratings yet
Display Documents Part2
9 pages
Legal and Technical Documents
PDF
No ratings yet
Legal and Technical Documents
23 pages
Mail Merge
PDF
No ratings yet
Mail Merge
12 pages
Troubleshooting
PDF
No ratings yet
Troubleshooting
14 pages
Maintaining Your Computer and Systems Requirements Notes
PDF
No ratings yet
Maintaining Your Computer and Systems Requirements Notes
4 pages
HTML Basics
PDF
No ratings yet
HTML Basics
6 pages
The Internet and Its Services
PDF
No ratings yet
The Internet and Its Services
18 pages
Network Hardware Devices
PDF
No ratings yet
Network Hardware Devices
1 page