Microsoft Access 2007 tutorial:SQL select statement

SQL select statement

XII. SQL Statements

SQL is a short form of Structured Query Language. It is used to retrieve, add, edit and delete data in a table.

XII.1. Select Statement


SELECT FieldName1, FieldName2,...

FROM TableName;

For example, use select statementto get all data from table Book(TblBook). To get the result, follow a few steps below:

- Click Create tap

- Click Query Design, in Macro group, on the Ribbon

- Click Close button of Show Table dialog box

Microsoft Access 2007 Show Table Dialog

- Right-click Query window as figure above

- Click SQL View

- Type Select Statement as figure below:

Microsoft Access 2007 Select Statement1

- To see result, click Mircosoft Access 2007 Run Icon

Note: To come back to SQL Code, click SQL View.



FROM TableName;

For instance, display all data from table Student(TblStudent).To do so follow the figure below:

Microsoft Access 2007 Select Statement2


SELECT FieldName1, FieldName2,...

FROM TableName

WHERE Condition;

For example, retrieve all data from table Product(TblProduct) that has UnitPrice greater than 15 dollars.

Microsoft Access 2007 Select Statement3


SELECT Table1.FieldName1, Table1.Name2

Table2.FieldName1, Table2.FieldName2,...

FROM Table1, Table2

WHERE how they are related to each other;

For instance, retrieve data from ProuctID and ProductName fields of table Product(TblProduct) and retrieve data from CategoryName field of table Category(TblCategory).

Microsoft Access 2007 Select Statement4


SELECT Table1.FieldName1, Table1.FieldName2

Table2.FieldName1, Table2.FieldName2,...

FROM Table1 INNER JOIN Table2 ON how they are related each other


For example, retrieve data from ProductID, ProductName, UnitPrice fields of table Product(TblProduct) and retrieve data from CategoryName field of table Category(TblCategory) where UnitPrice is greater than 15 dollars.

Microsoft Access 2007 Select Statement5


SELEC Field1,Field2,...

INTO Table2

FROM Table1;

Note: Both tables must have the same fields.

For example, copy all data from TblProduct to TblProduct1.

Microsoft Access 2007 Select Statement6



This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.