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
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
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
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
4/5 (6125)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (627)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brene Brown
4/5 (1148)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
4.5/5 (932)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4/5 (8214)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
4/5 (631)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1253)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4/5 (8365)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (860)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (877)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
4/5 (954)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
4.5/5 (361)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4/5 (2922)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
4.5/5 (484)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (277)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
4.5/5 (4972)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (444)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Tóibín
3.5/5 (2061)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
4/5 (4281)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
3.5/5 (447)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2283)
Yes Please
From Everand
Yes Please
Amy Poehler
4/5 (1987)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
4.5/5 (278)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
4/5 (1068)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (1993)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
3.5/5 (2641)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
4.5/5 (1936)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
4.5/5 (125)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (692)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (1912)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
4/5 (4074)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (830)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
4/5 (75)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (143)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (901)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2530)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M L Stedman
4.5/5 (790)
Presentation Software
PDF
No ratings yet
Presentation Software
6 pages
Mail Merge
PDF
No ratings yet
Mail Merge
12 pages
Intellectual Property , Copyright and Plagiarism
PDF
No ratings yet
Intellectual Property , Copyright and Plagiarism
4 pages
Display Documents Part2
PDF
No ratings yet
Display Documents Part2
9 pages
Envelopes and Labels
PDF
No ratings yet
Envelopes and Labels
3 pages
Legal and Technical Documents
PDF
No ratings yet
Legal and Technical Documents
23 pages
Troubleshooting
PDF
No ratings yet
Troubleshooting
14 pages
Literary Documents
PDF
No ratings yet
Literary Documents
6 pages
Network Hardware Devices
PDF
No ratings yet
Network Hardware Devices
1 page
HTML Basics
PDF
No ratings yet
HTML Basics
6 pages
Maintaining Your Computer and Systems Requirements Notes
PDF
No ratings yet
Maintaining Your Computer and Systems Requirements Notes
4 pages
The Internet and Its Services
PDF
No ratings yet
The Internet and Its Services
18 pages
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Little Women
From Everand
Little Women
Louisa May Alcott
4/5 (105)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carré
3.5/5 (109)
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Principles: Life and Work
From Everand
Principles: Life and Work
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Steve Jobs
From Everand
Steve Jobs
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Yes Please
From Everand
Yes Please
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
The Outsider: A Novel
From Everand
The Outsider: A Novel
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
John Adams
From Everand
John Adams
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
Presentation Software
PDF
Presentation Software
Mail Merge
PDF
Mail Merge
Intellectual Property , Copyright and Plagiarism
PDF
Intellectual Property , Copyright and Plagiarism
Display Documents Part2
PDF
Display Documents Part2
Envelopes and Labels
PDF
Envelopes and Labels
Legal and Technical Documents
PDF
Legal and Technical Documents
Troubleshooting
PDF
Troubleshooting
Literary Documents
PDF
Literary Documents
Network Hardware Devices
PDF
Network Hardware Devices
HTML Basics
PDF
HTML Basics
Maintaining Your Computer and Systems Requirements Notes
PDF
Maintaining Your Computer and Systems Requirements Notes
The Internet and Its Services
PDF
The Internet and Its Services
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
Little Women
From Everand
Little Women
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel