Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 22 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
22
Dung lượng
476,11 KB
Nội dung
WORKING WITH QUERIES 152 Create queries 1. Start Access, and open the FoodStore1 database. 2. In the Objects list, click Queries. 3. Double-click Create query in Design view. WORKING WITH QUERIES 153 The query Design View window should appear: 4. In the Show Table window, click Customers, then click the button. WORKING WITH QUERIES 154 5. Click the button. This adds the Customers table to the query. The query window should look like this: WORKING WITH QUERIES 155 Add fields to query 1. Drag the Customer ID field from the Customers table to the first column of the query design grid. Release the mouse button. The query design grid should look like this: WORKING WITH QUERIES 156 2. Drag the First Name field and Last Name field to the design grid the same way. The design grid should look like this: The query is now set up to show the Customer ID, First Name, and Last Name of each customer in the Customers table. WORKING WITH QUERIES 157 Run the query 1. On the Toolbar, click the icon. The query window should now look like this: WORKING WITH QUERIES 158 The query shows the Customer ID, First Name, and Last Name of each customer in the Customers table: WORKING WITH QUERIES 159 Sort results 1. On the Toolbar, click the icon to return to the query Design View. 2. In the Last Name field, click in the Sort row. When the drop-down arrow appears, click it, then click Ascending. WORKING WITH QUERIES 160 It should look like this: 3. On the Toolbar, click the icon. The query should run, and sort the records alphabetically by Last Name: 4. On the Toolbar, click the icon to return to the query Design View. WORKING WITH QUERIES 161 5. In the Customer Last Name field, click in the Sort row, then click (not sorted). It should look like this: [...]... Criteria row in the design grid should be blank: 3 Add the Company Name field to the query: Drag it from the field list in the Customers table and drop it in the blank field to the right of the State field in the design grid 1 68 WORKING WITH QUERIES 4 In the Company Name field, click in the Criteria row 5 Type: A* then press the ENTER key Tip: An asterisk (*) stands for any character or combination of... return to the FoodStore1 database window 170 WORKING WITH QUERIES Find duplicate records 1 Make sure Queries is selected in the Objects list 2 On the Toolbar, click the 3 When the New Query window appears, click Find Duplicates Query Wizard Then click the icon button WORKING WITH QUERIES 171 4 When the next screen appears, click Table: Customers, then click the 172 WORKING WITH QUERIES button 5 When... for any character or combination of characters For instance, Ap* would match Ape, Aptitude, Apparent, etc 6 Click the icon The query results should look like this: The query shows all companies whose names begin with A 7 On the Menu Bar, click File, then Save WORKING WITH QUERIES 169 8 When the Save As window appears, type: Companies that begin with A in the Query Name box 9 Click the 10 On the Menu... 1 In the query’s Customer table, scroll down to the State field 2 Add the State field to the query design grid 3 In the State field, click in the Criteria row 162 WORKING WITH QUERIES 4 Type: FL 5 Press the ENTER key It should look like this: WORKING WITH QUERIES 163 Tip: Notice that Access automatically surrounded the FL criterion with double quotes That’s because the State field stores text data In. .. database query language, double quotes signify a string of text If this field held date data, Access would have surrounded it with hash marks (#) If the field stored number data, Access wouldn’t have added anything 6 On the Toolbar, click the icon The query results should look like this: It has returned all customers who live in the State of FL 164 WORKING WITH QUERIES Employ Boolean operators What are... to a query They take their name from George Boole, the mathematician who first used them If you had a T-shirt store with an Access database, for instance, and you wanted to find out how many of your California customers had ordered blue T-shirts, you’d employ the AND operator in your query: customers from California AND who also bought blue T-shirts If you wanted to see how many customers were from... operator: customers from California OR customers who bought blue T-shirts WORKING WITH QUERIES 165 Employ the OR operator 1 Click the 2 In the State field, click in the or row under the criterion “FL” 3 Type: icon to return to the query Design View MD then press the ENTER key The design grid should look like this: 166 WORKING WITH QUERIES Tip: The two common Boolean operators are AND and OR They’re... ask yourself the purpose of the query: Do I want to find customers with a state of both Florida AND Maryland? No—a customer can’t be in two places at once Do I want to find customers with a state of either Florida OR Maryland? That makes sense, so this query would use the OR operator 4 Click the icon The query results should look like this: WORKING WITH QUERIES 167 Employ the AND operator 1 Click the... click Table: Customers, then click the 172 WORKING WITH QUERIES button 5 When the next screen appears, double-click First Name, then Last Name to add the fields to the query: Then click the button WORKING WITH QUERIES 173 . whose names begin with A. 7. On the Menu Bar, click File, then Save. WORKING WITH QUERIES 170 8. When the Save As window appears, type: Companies that begin with A in the Query. view. WORKING WITH QUERIES 153 The query Design View window should appear: 4. In the Show Table window, click Customers, then click the button. WORKING WITH QUERIES. window. WORKING WITH QUERIES 171 Find duplicate records 1. Make sure Queries is selected in the Objects list. 2. On the Toolbar, click the icon. 3. When the New Query window