Presentation on theme: "Databases Section 4: Select Queries Presented By: Lindani Ncube Based on Materials by: M Halse."— Presentation transcript:
Databases Section 4: Select Queries Presented By: Lindani Ncube Based on Materials by: M Halse
Simple Select Queries A SIMPLE select query (can only be performed on one table) can be used to: choose one column to display choose multiple columns to display from one able limit the data in one column with Criteria limit the data in multiple specific columns Select queries vs. Simple select queries A select query retrieves data and values from one or more tables where as a simple select query can only be performed on one table. The results are displayed of both types of queries are displayed in a datasheet view.
Using the Query Wizard for a simple Select Query Click on Query Wizard in the Queries group in the create tab of the ribbon For both Simple select queries and normal select queries use the Simple query wizard
Using the Query Wizard for a simple Select Query
Creating a Select Query in Design View Click on the Query design button in the Queries group of the Create tab on the Ribbon A Query Tools Design tab appears on the Ribbon
Creating a Select Query In Design View Add all the tables you need to perform your query. This can be one or more tables. You can add more later by using the Show Table button
Creating a Select Query In Design View Either Click on the selection button on the design tab of the Ribbon, OR Right click on the query background area. In the context menu provided, choose Select Query from Query Type OR
Creating a Select Query In Design View This is what you will see when you have created your query in design view:
Creating a Select Query in Design View
You can choose to sort (ascending [A-Z] or descending [Z- A]) by one or more Fields You can choose whether you want a column to be visible in the result or not, even if you apply criteria to the column You can specify select criteria
Creating a Select Query in Design View This query is equivalent to the MySQL statement it creates behind the scenes: SELECT Wines.Name, Wines.[White/Red/Rose], Wines.Type, Wines.Price FROM Wines WHERE (((Wines.Price)<200)) ORDER BY Wines.Name; This can be viewed by choosing SQL View from the View button
Saving a Query Run the query by pressing the Run button. The results of the query look like this i.e. they will be shown to you in datasheet view. Remember to save your query with a name that will indicate what data it extracts.
Editing a Query Double click on the query in the Navigation Pane Switch to Design View and then edit your query. Remember to save if you want to keep the changes.
Section 4 Summary Using the Query Wizard for a Select Query Creating a Select Query in Design View Saving a Query Editing a query