Queries Chapter 5
Queries Chapter 5
Queries Chapter 5
Query:
The word Query is derived from the English word Question and Inquiry. Which means to ask, i.e. to get information about
someone. Query in Microsoft X MS Access is used to view existing data, find required data, change existing data and
analyze data and based on this Query Forms and Reports are created. Can also be prepared.
For example, if we want to find a specific record in the existing data, we use the Query object of MS-Access. For example,
suppose we have to select only those students who have passed from the result data of all students. Similarly, if we need
to change any record in the existing data, for example, if the address of a student changes, then in the data. We also have
to use Query to make this change.
Query refers to getting some information regarding the store data in the table and performing some action on data.
1. Select Query 2 Parameter Query (Parameter Query) 3 Cross Tab Query 4- Action Query (Action Query)
1 Select Query:
This is the most used query. This Query retrieves the required data from one or more files.
Shows space together. We know that a well-designed data is often more data about an object
It is stored in more than one wallet, so searching for your required data separately in multiple wallets is quite tedious and
time consuming.
1. Open database
2. Click on queries
3. in the main database window select create query in design view
4. show table dialogue box will appear in it tables list will appear
5. select the tables and then click on close button
6. in the next there are different options are avail for to make query
7. "Double-click on the required fields in the tables to add them to the query."
8. . If you want to view yours in a specific order (Descending or Ascending), select Descending Ascending in the desired
column through the Sort option in the query grid
9. If you want to look at a specific record, use the Query Design Grid. Enter the conditions in the required field by
Criteria.
10.To save the query, click the Save button in the standard toolbar or click Save in the File menu, and the Save As
dialog box will open. Type the name of the query in it and click the Ok button.
11.Click run button
12.Results will shown
Follow these steps to create a Select Query using the Query Wizard:
1. In the Main Data window, click on "Queries" from the list of Objects.
2. Click "New" in the standard toolbar of the main data window. The "New Query" dialog box will appear. Select "Simple
Query Wizard" and press the "OK" button. Alternatively, double-click the "Create Query by Using Wizard" option in the
right part of the main data window.
3. The "Simple Query Wizard" dialog box will open. In the "Table/Queries" section, select the tables or queries to use in
the query from the list.
4. In the "Available Fields" list, select the required fields using the arrow buttons:
Parameter Query :
A parameter query is a type of query that prompts the user for input data through a dialog box when it's run. This input
data is then used as criteria to generate results. The input provided by the user is called a parameter, and multiple
parameters can be used in a single query.
Parameter queries are particularly useful when creating forms and reports. For example, suppose you want to generate a
monthly sales report. You can create a query to view monthly sales and then create a report based on this query. When
you run the report, a dialog box will appear, allowing you to enter the desired month and generate the sales report for
that month.
1. Open the required data and click on "Queries" from the list of Objects.
2. Click "New" in the main data window's standard toolbar and select "Create Query in Design View".
3. Add one or more tables from the "Show Tables" dialog box.
4. The Query Design Grid will appear with fixed columns at the top. Choose the required fields from the section below.
5. In the "Criteria" section, write a message in square brackets instead of a value between the required fields. This
message will appear as a runtime dialog box, prompting the user for input.
6. Write the rule number in brackets below the field and in front of the criteria row."
9. type roll no
Crosstab Query:
A Crosstab Query is used to compare and analyze data from two groups. One group is displayed in rows, while the other is
displayed in columns. This query allows you to examine different types of data and perform arithmetic operations like
addition, averaging, and more.
Crosstab Query helps you compare and analyze data by arranging it in rows and columns. For instance, if you want to see
the number of items sold on different dates, a Crosstab Query is ideal.
2. In the Main Data window, click on "Queries" from the list of Objects.
3. Click "New" in the main data window, and the "New Query" dialog box will appear. Select "Crosstab Query
Wizard" and click "OK".
4 .Select your table and click the "Next" button.
5. From the list of available fields, use the arrow button to select the field whose data you want to display in the book, and
then click the "Next" button.
6. Now, select the field that you want to display as a column and click "Next" again."
7.type the name of cross tab query then ok results will show on sacreen
Action Query :
An Action Query is a type of query that allows you to modify records in a database and move records from one place to
another. There are four types of Action Queries:
4. Make Table Query: Creates a new table from existing data in a database.
Use of
In a query, criteria are used to retrieve specific records. When we apply criteria to a query, it will only display the records
that meet the specified conditions, rather than showing all the records in the table.
For example, we might want to view only the records of students who have passed or only the customers who live in
Muzaffargarh city. To apply criteria in a query, we need to use operators.
The purpose of a query in Microsoft Access is to find and work with data in a database. Queries can be used to
find a specific records in database
2- Types of qury:
1- Select query
2- Parameter query
3- Crosstab Curie
4- Action query
3- Select query:
A select query is a database object that shows information in Datasheet view. A query does not store data, it
displays data that is stored in tables. A query can show data from one or more tables, from other queries, or from
a combination of the two.
A crosstab query calculates a sum, average, or other aggregate function, and then groups the results by two
sets of values— one set on the side of the datasheet and the other set across the top.
5- Parameter query:
A parameter query is a query that, when run, first retrieves data from you using a dialog box and
sets conditions on that data.
6- Action query:
Action queries are queries that make changes to many records at once. They are used to delete records, to
update records
A wildcard is a special character used to represent one or more characters in a search query.
2. What is the use of Asterisk in Wild Cards?:
The asterisk (*) is used to represent any number of characters in a wildcard search.
The question mark (?) is used to represent a single character in a wildcard search.
Action Queries
1. Delete Query
2. Update Query
3. Append Query
A Make Table Query creates a new table from existing data in a database.
1. They are used to display and interact with data in a user-friendly way.
2. They can be customized to meet specific needs and display data in a specific format.
Criteria refer to the conditions or rules used to filter or select specific data in a query.
In Access, the number sign (#) is used as a wildcard character to represent dates or times in a query.