Access and Condition Statements

Slides:



Advertisements
Similar presentations
Query in Microsoft Access. Lesson plan Expression in Microsoft Access Create a query.
Advertisements

Program Design and Development
Queries and SQL in Access Please use speaker notes for additional information!
CORE 2: Information systems and Databases STORAGE & RETRIEVAL 2 : SEARCHING, SELECTING & SORTING.
Database Queries. Queries Queries are questions used to retrieve information from a database. Contain criteria to specify the records and fields to be.
SQL and Conditions Speaker notes will provide additional information!
Introduction to Access 2010 CIS120first.accdb is the database I am creating.
I want to do SQL, I start as if I am doing a regular query.
Assignment statement: Assigns a value to a variable Variable must appear on the left side, value on the right side of the assignment operator Right side.
A am going to create a table in design view. I am going to create a table in an Access database that contains information about the books that I have on.
Finish ing the logic flowc harts from week 3.. if invcd = “A” and (amtfst > 500 or amtsnd > 200) move “OKAY” to msg end if With the parenthesis, invcd.
Creating a database - I clicked on blank database and am saving it as books10.mdb. For more information see the practice example under week #1. I am going.
IF Statements flowcharts and pseudocode Please open the speaker notes - they contain additional information!
The data in the table.. Starting a query. Two criteria in an AND relationship.
DEVRY CIS 170 C I L AB 2 OF 7 D ECISIONS Check this A+ tutorial guideline at decisions For.
Objective #5: Solve Compound Inequalities
CHAPTER 7 DATABASE ACCESS THROUGH WEB
3.5 Databases Relationships.
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
This shows the user interface and the SQL Select for a situation with two criteria in an AND relationship.
On new..
Single Table Queries in SQL
Unit 2 Smarter Programming.
Access Database for CIS17
MySQL - Creating donorof database offline
Please use speaker notes for additional information!
Database Queries.
Please use speaker notes for additional information!
Designing an Algorithm
follow this structure. Creating records following the structure of the table is populating the table.
Using Access 2016 Since we are creating a new Access database, we need to select blank database.
Objectives After studying this chapter, you should be able to:
Week 3. criteria must be true..
Using SQL with Access I am adding queries to the stu table in SecondDB.accdb – a database that I created in class. SQL stands for structured query language.
1) C program development 2) Selection structure
Miscrosoft Office..
I am opeing Access 2003 in the Microsoft Office.
Introduction to Views and Reports
Algorithm Discovery and Design
If selection construct
Computational Thinking for KS3
You can read it better when I make the change.
These are user interface queries
On new..
If selection construct
Access Database for CIT12
Essential Questions What is a denominator? What is a numerator?
Chapter 5: Control Structure
We are starting JavaScript. Here are a set of examples
Searching an Array or Table
SELECTIONS STATEMENTS
Please use speaker notes for additional information!
If statements (Inven1, Inven2, Inven2a, Inven3, Inven3a)
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Done with SQL..
This is the example I want the class to put up to become comfortable with creating and populating a table in Access.
Chapter 3: Selection Structures: Making Decisions
Notes on SQL This slide show will introduce SQL using Access. It assumes only an introductory level of knowledge about Access.
Queries.
Introduction to Access 2010
Chapter 3: Selection Structures: Making Decisions
Queries and SQL in Access
Databases and Information Management
Course 2: Inequalities Objectives:
Starter.
Using SQL with Access I create a database named
I am now going to do queries in SQL
either of two other things (an OR relationship between them)
Template for the portfolio.
Access Click on file and then you want a new database.
Presentation transcript:

Access and Condition Statements Please use speaker notes for additional information! This presentation will deal with conditional statements in Access. We will deal with complex conditions involving AND and OR.

This shows the data that I have in the table called tablestu This shows the data that I have in the table called tablestu. The structure is on the next slide.

This is the structure of the data This is the structure of the data. Notice that only gpa and credits are numbers. The gpa is single to allow for decimal places and the credits is an integer. Note also that the key is idno.

I am asking for all records where the major = “CI” I am asking for all records where the major = “CI”. Note that this can be written as =“CI” but Access decides you do not need the = and eliminates it. Essentially equal is the default. This shows the simple query of asking for all CI majors. There are 14 records in the table. Seven of these records have the major CI. As a result of this query, those records are shown.

Problem: I want to display the record for all students that have a major = “CI”, a state = “MA” and credits > 15. Logic flowchart: Pseudocode: if major = “CI” then if state = “MA” then if credits > 15 then display record endif major=“CI” No Yes state=“MA” No Yes credits > 15 No Yes This shows a problem, the logic flowchart showing the solution and the pseudocode showing the logic to solve the problem. The solution in Access is shown on the next slide. This is the AND structure. In this example there are three things that must be true, it could have been two or four etc. Display in list

This shows asking for all records where major = "CI" and state = "MA" and credits is > 15. Note that CI and MA are in quotes because they are text. 15 is a numeric so it is not in quotes.

Problem: I want to display the record for all students that have a major = “CI” or a major of “BU”. No Yes Pseudocode: if major = “CI” then display record else if major = “BU” then endif Display in list major=“BU” No Yes Display in list This shows the problem, the logic flowchart and the pseudocode for a simple OR structure. One or the other of these has to be true. It does not matter which is true. The Access for this query is shown on the next slide.

In this example I want major to be either “CI” OR “BI” In this example I want major to be either “CI” OR “BI”. Notice that I have the first thing under criteria and the second under OR. Only one record does not meet the criteria - 13 out of the 14 records are either CI or BU majors. Note that when I want an AND relationship the criteria are on the same line. When I want an OR relationship the criteria are on different lines.

Problem: I want to display the record for all students that have a major = “CI”AND either the gpa is greater than 3.5 or the credits is > 30. Flowchart: Pseudocode: if major = “CI” then if gpa > 3.5 then display record else if credits > 30 then endif major=“CI” No Yes gpa > 3.5 No Yes credits > 30 Display in list Yes No Display in list If major is = to “CI” then I can continue and ask the other questions. If major is not = “CI” then I am done. Once I have established that major is equal to “CI” then I have a standard OR where I am asking whether the gpa > 3.5 OR credits > 30. The structure is that the first question needs to be true and then either of the remaining questions have to be true. This shows the flowchart and pseudocode for a structure that uses both AND and OR.

In many languages this would be written as: Access requires that you repeat the “CI” on both lines. Essentially, Access makes you ask the question as is major = “CI” and gpa > 3.5 OR is major = “CI” and credits > 30. This is because of the limitations of the user friendly query in Access. In many languages this would be written as: if major=“CI” and (gpa > 3.5 or credits > 30) As you will see, logic dictates that ANDs get resolved before ORs. This means that things around the AND get processed together. In this example, I want the OR to group two things together. I can change the order of operations by using the parenthesis to group the OR conditions so it read major = “CI” and either of the other conditions. This shows the results. Notice that all people have CI and that two of them are there because the gpa is greater than 3.5 and one of them is there because credits is greater than 30. Note that Access does provide a more extended way to do queries using SQL.