SlideShare a Scribd company logo
9/8/2014 Access Tips: Access and SQL Part 1: Setting the SQL Scene 
| Home | Excel | Access | Word | Outlook | FrontPage | VBA | Downloads | Index | 
Access & SQL 1 
Access Home 
C ontinue the 
tutorial: 
Part 1: 
Introduction 
Part 2: VBA & 
SQL 
Part 3: Examples 
Part 4: Building 
Queries 
Part 5: More 
Instant Queries 
Part 6: Dynamic 
Reports 
Printer Friendly 
Version 
Access and SQL 
Part 1: Setting the SQL Scene 
This is the first in a series of tutorials demonstrating how you can use SQL to build a better 
database. The tutorials are not intended to be a course on SQL. There are many excellent 
books and online tutorials on the subject, some of which are listed below. 
In this tutorial I review the various tasks that SQL is used for in Access and answer some of 
the questions that I asked when I started to explore the language. 
What is SQL? 
What is SQL for? 
C an SQL do things that the Query Design tool can't? 
Do I need to know SQL? 
Online resources for SQL. 
Books on SQL. 
What is SQL? 
SQL is Structured Query Language. Some people say "Ess Queue Ell" and others prefer 
"Sequel". SQL has been around for a while. It started life in the late 1970s when computer 
database designers needed a language they could use to talk to the first relational databases 
(ones in which the data was stored in multiple, linked tables - Access is a relational database). 
The first SQL standard was published by ANSI in 1986 and it has been updated several times 
since then. Although it is intended to be a standard language, many "dialects" exist. Microsoft 
Access uses a dialect called Jet SQL whereas its cousin Microsoft SQL Server uses T-SQL. But 
the core language is supported by many programs and is essentially simple and easy to learn. 
An SQL statement might look something like this: 
SELECT tblStaff.* FROM tblStaff WHERE tblStaff.Gender="M"; 
This statement says "show me all the fields from the tblStaff table for record where the Gender 
field is 'M'." This is a simple example but it illustrates how easy the SQL language is to 
understand. 
^ top 
What is SQL for? 
SQL is used to interact with your database's data. Access uses SQL for many tasks: whenever 
a query is run it uses SQL to filter the data; whenever a report is displayed SQL is used to 
gather the data to be displayed; SQL provides the data displayed on an Access form. 
Running Queries 
Access provides the user with a friendly interface, the query Design View, for building queries. 
This view offers a graphical representation of the query and the user requires no knowledge of 
SQL to use it. When the user "runs" the query Access translates the graphical representation 
into an SQL statement which it passes to its Jet Database Engine. Jet returns the appropriate 
data which Access displays in the query Datasheet View. 
Point at the icons below to display the Query view... 
Design View SQL View Datasheet View 
http://www.fontstuff.com/access/acctut14.htm 1/6
9/8/2014 Access Tips: Access and SQL Part 1: Setting the SQL Scene 
In this series of tutorials you will find out how to build new queries and change existing queries 
using VBA and SQL, and find out why many professional database developers prefer not to use 
stored queries at all. 
Filtering and Sorting Forms and Reports 
Access forms offer the user the opportunity to filter and sort the recordset being displayed. 
This is done by choosing an option from the Records menu or from the form's own right-click 
context menu. Several options are available. 
When a filter is chosen Access applies an SQL WHERE clause to the form's Filter property. The 
illustration below shows a form being filtered and the resulting property value being shown in 
the form's property sheet: 
>>> 
Similarly, when a sort order is chosen Access applies an ORDER BY clause to the form's 
Order By property: 
>>> 
Both of these properties can be set using VBA in both forms and reports. If fact, a report's 
Filter and Order By properties can only be changed by the user in the report's design view. 
This series of tutorials will show you how to write VBA and SQL code to filter and sort forms 
and reports at run-time and create powerful tools for the user. 
Specifying the Recordset Displayed by a Form or Report 
When you build a form or report, the purpose of which is to display data, you have to specify 
the recordset on which it is based. This information is stored as the object's Recordset 
property. Once set, this property can not be changed by the user without going into the 
object's design view, which requires knowledge of form or report design and is time-consuming. 
Although you are unlikely to want to change the recordset property of a form it is common for 
database users to want a standardised report design. Many people deal with this by creating 
multiple copies of the report, but with VBA you can use just one report and change its 
http://www.fontstuff.com/access/acctut14.htm 2/6
9/8/2014 Access Tips: Access and SQL Part 1: Setting the SQL Scene 
recordset as many times as you want, simply by creating an SQL statement for each report 
you want to display. 
These are just some of the things that SQL is be used for in an Access database. 
^ top 
Can SQL do things that the Query Design tool can't? 
Access uses SQL to perform all the data functions of its Query Design tool, including the 
various "action" queries (Make Table, Append, Update and Delete). All these functions can be 
achieved using very simple VBA statements combined with SQL without the need to use the 
query design tool or to maintain any stored queries. 
There a number of functions that can be performed using SQL that can not be represented by 
the QBE grid (QBE = Query By Example) and can only be executed by creating the SQL 
manually, either by entering it into the SQL view window or by using VBA. Access refers to 
these functions as SQL Specific Queries. Access lists these on the Query menu: 
There are three kinds of SQL Specific queries: the Union Query, the Pass-Through Query and 
the Data Definition Query. Here's what they do: 
The Union Query 
Union queries simultaneously query separate datasets (either tables or other queries) and 
combine the result into a single recordset. This is not the same as querying linked tables. The 
datasets must have a similar structure (the data types must match but field names need not be 
the same). 
For example, you might have a Suppliers table and a Customers table and you want to create a 
phone list from both sets of data. If you were restricted to using the QBE grid, you would have 
to create two queries, one for each table, and then combine the results. A Union query can 
interrogate both tables at the same time and present the results as a single set of data. 
The Pass-Through Query 
Pass-Through queries are useful when you want to query data in another server-type database 
(such as Microsoft SQL Server or Oracle) that has its own more powerful database engine 
running on a network server. The query is designed in the SQL view of Access (or with VBA) 
but when run it is sent direct to the server where it is executed, bypassing the Access Jet 
engine. The result is returned to Access and displayed in the normal way, and the need to have 
a linked table in the Access database is eliminated. 
The Data Definition Query 
Data Definition queries open up a completely different range of possibilities. They are used to 
create and modify tables. Fields can be defined and their properties specified. Fields and tables 
can be deleted. Relationships and indexes can be created and defined. 
Data Definition queries are a very powerful tool in the SQL language and can perform many 
tasks on the structure of a database without recourse to VBA programming. 
SQL Can Make Query Design Easier! 
The QBE grid of the Query design window is a very useful tool, but sometimes it is easier to 
write SQL directly into the SQL View than to try to represent it on the grid. An example of this 
is specifying the sort order of a query. Here is a (very) simple example to illustrate the point: 
Suppose you want to sort your query by two columns. In the QBE grid you specify the sort 
direction of each column: 
http://www.fontstuff.com/access/acctut14.htm 3/6
9/8/2014 Access Tips: Access and SQL Part 1: Setting the SQL Scene 
But Access determines the sort order by the position 
of the columns in the QBE and sorts left-to-right. 
Here the data is sorted first by Firstname then by 
Lastname. But what if you wanted to sort the other 
way? Rearranging the columns would mean that the 
Lastname field would appear before the firstname 
field and you might not want that! 
>>> 
The answer is to specify the correct sort order in the SQL: 
>>> 
The SQL SELEC T clause determines the order in which the data is displayed and the ORDER BY 
clause determines the sort order. Getting the desired sort order is simply a matter of editing 
the ORDER BY clause. Here's how you would have to represent that in the QBE grid: 
To get this result in using the QBE grid you have to enter 
additional columns (remembering to uncheck their "show" 
option). This is a very simple example. With multiple 
columns and a complex sort order there is a lot more to 
do. 
Whatever way you do it the result is the same. The data 
is displayed in the order Firstname, Lastname but the sort 
order is Lastname, Firstname. 
NOTE: When you make changes the query's SQL view 
Access modifies the QBE grid to represent the new SQL 
statement graphically. 
^ top 
Do I need to know SQL? 
Most database users don't need to know SQL. Anyone who has built a anything but the most 
basic of queries using the Access query design window has already been using SQL without 
knowing it. C riteria like: Between #01/01/2003# AND #01/07/2003# or Not("London") or 
http://www.fontstuff.com/access/acctut14.htm 4/6
9/8/2014 Access Tips: Access and SQL Part 1: Setting the SQL Scene 
In("London", "Paris", "NewYork") are all phrases from the SQL language. 
Access contains many tools and wizards that hep the user create a powerful database without 
having to learn SQL. But if you are at all serious about database building (and the fact that you 
are reading this suggests that you are!) a knowledge of SQL will help you build better, more 
powerful databases. So my answer is an emphatic "YES!". 
But don't panic... this doesn't mean that you have to go on an SQL course right away, or even 
buy a book (although there are plenty of excellent books and online resources on the subject). 
I started learning SQL by building queries in the Access query design window, then looking at 
the SQL that was Access generated in the SQL View. It's an excellent way to learn the basics. 
And if you follow this series of tutorials you should learn enough to help you figure out the rest 
yourself. 
^ top 
Online Resources for SQL 
There is plenty of SQL reference material available free on the web. Just go to your favourite 
search engine and type in "SQL tutorial" for a (large) selection. I had planned to include a 
selection here but most of them are pretty turgid and don't make easy reading. Whilst I 
suppose it isn't fair to complain when it's free, it is often difficult to find the SQL amongst the 
plethora of adverts and pop-ups. Anyway, you've found me so you're in the best place! 
For an overview of SQL try W3 Schools - Learn SQL which has introductory and advanced 
SQL tutorials at http://www.w3schools.com/sql/ 
^ top 
Books on SQL 
Most good books on Microsoft Access and Access development will have a section on SQL so 
take a look at the Access page of my bookshelf section. 
I have only one book on SQL. I bought it when I was considering a project working with both 
Microsoft Access and Microsoft SQL Server, but it is an excellent and very readable introduction 
for the newcomer to SQL as well as a vital reference work for anyone considering working with 
both programs: 
SQL: Access to SQL Server 
Susan Sales Harkins, Martin Reid 
Apress ISBN: 1893115305 
Find this book at Amazon.com (USA) 
Find this book at Amazon.co.uk (UK) 
^ top 
What's Next? 
The next tutorial in this series will explain how to incorporate SQL into VBA code: 
Access and SQL Part 2: Putting VBA and SQL Together 
^ top 
http://www.fontstuff.com/access/acctut14.htm 5/6

More Related Content

PPT
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
PDF
Sq lite module8
PDF
Sq lite module6
PPT
Internet Environment
PDF
Oracle SQL Part1
PDF
Sq lite module5
PPT
forms builder
PPT
4) databases
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
Sq lite module8
Sq lite module6
Internet Environment
Oracle SQL Part1
Sq lite module5
forms builder
4) databases

What's hot (20)

DOC
Oracle report from ppt
PDF
Using T-SQL
PDF
Oracle SQL Part 2
PDF
Oracle advanced queuing
PDF
Oracle SQL Part 3
PPT
Oracle D2K reports
PPT
Rational Publishing Engine with Rational DOORS
PPTX
Database application and design
PDF
XLS PE How To Tutorials Tips & Tricks
DOCX
PDF
SQL Commands
PDF
Introduction to Oracle Fusion BIP Reporting
PDF
Access tips access and sql part 3 practical examples
PPT
Oracle Forms Tutorial (www.aboutoracleapps.com)
PDF
Sql Server 2014 Course Content
PPTX
Technical stream presentation
PDF
Sq lite module9
PDF
Responsive Design and Bootstrap
PPTX
Data weave documentation
DOCX
OBIEE publisher with Report creation - Tutorial
Oracle report from ppt
Using T-SQL
Oracle SQL Part 2
Oracle advanced queuing
Oracle SQL Part 3
Oracle D2K reports
Rational Publishing Engine with Rational DOORS
Database application and design
XLS PE How To Tutorials Tips & Tricks
SQL Commands
Introduction to Oracle Fusion BIP Reporting
Access tips access and sql part 3 practical examples
Oracle Forms Tutorial (www.aboutoracleapps.com)
Sql Server 2014 Course Content
Technical stream presentation
Sq lite module9
Responsive Design and Bootstrap
Data weave documentation
OBIEE publisher with Report creation - Tutorial
Ad

Viewers also liked (15)

PDF
2nd examiners report
PDF
Access tips access and sql part 4 building select queries on-the-fly
PDF
Access tips access and sql part 6 dynamic reports
PDF
Shares course 01
PDF
Accelerating Learning for Business Impact - NuVeda Corporate Presentation
PPT
Женское здорове TianDe
PPT
Mechanics of facilitation
PDF
Access tips access and sql part 2 putting vba and sql together
PDF
Access tips access and sql part 5 more instant queries 1
PPTX
Facebook
 
PDF
Storyboard pro 2_sp1_user_guide
DOCX
Job description
PPT
Tprs workshop
PDF
Ciclo de cine
PDF
Convocatoriacsutcb
2nd examiners report
Access tips access and sql part 4 building select queries on-the-fly
Access tips access and sql part 6 dynamic reports
Shares course 01
Accelerating Learning for Business Impact - NuVeda Corporate Presentation
Женское здорове TianDe
Mechanics of facilitation
Access tips access and sql part 2 putting vba and sql together
Access tips access and sql part 5 more instant queries 1
Facebook
 
Storyboard pro 2_sp1_user_guide
Job description
Tprs workshop
Ciclo de cine
Convocatoriacsutcb
Ad

Similar to Access tips access and sql part 1 setting the sql scene (20)

PDF
Introduction to sql server
PPT
Ebook7
PPT
Sql interview question part 7
PPTX
Ebook11
PDF
Sql server 2012 tutorials writing transact-sql statements
PPT
Ebook8
PPT
Sql interview question part 8
PPT
New features of sql server 2005
PDF
Database Systems Design Implementation and Management 11th Edition Coronel So...
PDF
Database Systems Design Implementation and Management 11th Edition Coronel So...
PPTX
Oracle application express
PPTX
Oracle application express ppt
PDF
Database Systems Design Implementation and Management 11th Edition Coronel So...
PDF
SQL Complete Tutorial. All Topics Covered
PDF
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
PPTX
introduction to SQL query language beginner.ppt
PPTX
Sql interview question part 6
PPTX
Ebook6
PPTX
Sql interview-question-part-6
PPTX
Ebook6
Introduction to sql server
Ebook7
Sql interview question part 7
Ebook11
Sql server 2012 tutorials writing transact-sql statements
Ebook8
Sql interview question part 8
New features of sql server 2005
Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...
Oracle application express
Oracle application express ppt
Database Systems Design Implementation and Management 11th Edition Coronel So...
SQL Complete Tutorial. All Topics Covered
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
introduction to SQL query language beginner.ppt
Sql interview question part 6
Ebook6
Sql interview-question-part-6
Ebook6

Recently uploaded (20)

PPTX
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PDF
Taxes Foundatisdcsdcsdon Certificate.pdf
PPTX
Computer network topology notes for revision
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PDF
Clinical guidelines as a resource for EBP(1).pdf
PDF
Launch Your Data Science Career in Kochi – 2025
PPTX
Business Acumen Training GuidePresentation.pptx
PPTX
Measurement of Afordability for Water Supply and Sanitation in Bangladesh .pptx
PPTX
IB Computer Science - Internal Assessment.pptx
PPTX
Challenges and opportunities in feeding a growing population
PPTX
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
PPT
Quality review (1)_presentation of this 21
PDF
Fluorescence-microscope_Botany_detailed content
PPT
Chapter 3 METAL JOINING.pptnnnnnnnnnnnnn
PPTX
climate analysis of Dhaka ,Banglades.pptx
PPTX
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
PPTX
batch data Retailer Data management Project.pptx
PPTX
Understanding Prototyping in Design and Development
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
oil_refinery_comprehensive_20250804084928 (1).pptx
Taxes Foundatisdcsdcsdon Certificate.pdf
Computer network topology notes for revision
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
Clinical guidelines as a resource for EBP(1).pdf
Launch Your Data Science Career in Kochi – 2025
Business Acumen Training GuidePresentation.pptx
Measurement of Afordability for Water Supply and Sanitation in Bangladesh .pptx
IB Computer Science - Internal Assessment.pptx
Challenges and opportunities in feeding a growing population
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
Quality review (1)_presentation of this 21
Fluorescence-microscope_Botany_detailed content
Chapter 3 METAL JOINING.pptnnnnnnnnnnnnn
climate analysis of Dhaka ,Banglades.pptx
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
batch data Retailer Data management Project.pptx
Understanding Prototyping in Design and Development

Access tips access and sql part 1 setting the sql scene

  • 1. 9/8/2014 Access Tips: Access and SQL Part 1: Setting the SQL Scene | Home | Excel | Access | Word | Outlook | FrontPage | VBA | Downloads | Index | Access & SQL 1 Access Home C ontinue the tutorial: Part 1: Introduction Part 2: VBA & SQL Part 3: Examples Part 4: Building Queries Part 5: More Instant Queries Part 6: Dynamic Reports Printer Friendly Version Access and SQL Part 1: Setting the SQL Scene This is the first in a series of tutorials demonstrating how you can use SQL to build a better database. The tutorials are not intended to be a course on SQL. There are many excellent books and online tutorials on the subject, some of which are listed below. In this tutorial I review the various tasks that SQL is used for in Access and answer some of the questions that I asked when I started to explore the language. What is SQL? What is SQL for? C an SQL do things that the Query Design tool can't? Do I need to know SQL? Online resources for SQL. Books on SQL. What is SQL? SQL is Structured Query Language. Some people say "Ess Queue Ell" and others prefer "Sequel". SQL has been around for a while. It started life in the late 1970s when computer database designers needed a language they could use to talk to the first relational databases (ones in which the data was stored in multiple, linked tables - Access is a relational database). The first SQL standard was published by ANSI in 1986 and it has been updated several times since then. Although it is intended to be a standard language, many "dialects" exist. Microsoft Access uses a dialect called Jet SQL whereas its cousin Microsoft SQL Server uses T-SQL. But the core language is supported by many programs and is essentially simple and easy to learn. An SQL statement might look something like this: SELECT tblStaff.* FROM tblStaff WHERE tblStaff.Gender="M"; This statement says "show me all the fields from the tblStaff table for record where the Gender field is 'M'." This is a simple example but it illustrates how easy the SQL language is to understand. ^ top What is SQL for? SQL is used to interact with your database's data. Access uses SQL for many tasks: whenever a query is run it uses SQL to filter the data; whenever a report is displayed SQL is used to gather the data to be displayed; SQL provides the data displayed on an Access form. Running Queries Access provides the user with a friendly interface, the query Design View, for building queries. This view offers a graphical representation of the query and the user requires no knowledge of SQL to use it. When the user "runs" the query Access translates the graphical representation into an SQL statement which it passes to its Jet Database Engine. Jet returns the appropriate data which Access displays in the query Datasheet View. Point at the icons below to display the Query view... Design View SQL View Datasheet View http://www.fontstuff.com/access/acctut14.htm 1/6
  • 2. 9/8/2014 Access Tips: Access and SQL Part 1: Setting the SQL Scene In this series of tutorials you will find out how to build new queries and change existing queries using VBA and SQL, and find out why many professional database developers prefer not to use stored queries at all. Filtering and Sorting Forms and Reports Access forms offer the user the opportunity to filter and sort the recordset being displayed. This is done by choosing an option from the Records menu or from the form's own right-click context menu. Several options are available. When a filter is chosen Access applies an SQL WHERE clause to the form's Filter property. The illustration below shows a form being filtered and the resulting property value being shown in the form's property sheet: >>> Similarly, when a sort order is chosen Access applies an ORDER BY clause to the form's Order By property: >>> Both of these properties can be set using VBA in both forms and reports. If fact, a report's Filter and Order By properties can only be changed by the user in the report's design view. This series of tutorials will show you how to write VBA and SQL code to filter and sort forms and reports at run-time and create powerful tools for the user. Specifying the Recordset Displayed by a Form or Report When you build a form or report, the purpose of which is to display data, you have to specify the recordset on which it is based. This information is stored as the object's Recordset property. Once set, this property can not be changed by the user without going into the object's design view, which requires knowledge of form or report design and is time-consuming. Although you are unlikely to want to change the recordset property of a form it is common for database users to want a standardised report design. Many people deal with this by creating multiple copies of the report, but with VBA you can use just one report and change its http://www.fontstuff.com/access/acctut14.htm 2/6
  • 3. 9/8/2014 Access Tips: Access and SQL Part 1: Setting the SQL Scene recordset as many times as you want, simply by creating an SQL statement for each report you want to display. These are just some of the things that SQL is be used for in an Access database. ^ top Can SQL do things that the Query Design tool can't? Access uses SQL to perform all the data functions of its Query Design tool, including the various "action" queries (Make Table, Append, Update and Delete). All these functions can be achieved using very simple VBA statements combined with SQL without the need to use the query design tool or to maintain any stored queries. There a number of functions that can be performed using SQL that can not be represented by the QBE grid (QBE = Query By Example) and can only be executed by creating the SQL manually, either by entering it into the SQL view window or by using VBA. Access refers to these functions as SQL Specific Queries. Access lists these on the Query menu: There are three kinds of SQL Specific queries: the Union Query, the Pass-Through Query and the Data Definition Query. Here's what they do: The Union Query Union queries simultaneously query separate datasets (either tables or other queries) and combine the result into a single recordset. This is not the same as querying linked tables. The datasets must have a similar structure (the data types must match but field names need not be the same). For example, you might have a Suppliers table and a Customers table and you want to create a phone list from both sets of data. If you were restricted to using the QBE grid, you would have to create two queries, one for each table, and then combine the results. A Union query can interrogate both tables at the same time and present the results as a single set of data. The Pass-Through Query Pass-Through queries are useful when you want to query data in another server-type database (such as Microsoft SQL Server or Oracle) that has its own more powerful database engine running on a network server. The query is designed in the SQL view of Access (or with VBA) but when run it is sent direct to the server where it is executed, bypassing the Access Jet engine. The result is returned to Access and displayed in the normal way, and the need to have a linked table in the Access database is eliminated. The Data Definition Query Data Definition queries open up a completely different range of possibilities. They are used to create and modify tables. Fields can be defined and their properties specified. Fields and tables can be deleted. Relationships and indexes can be created and defined. Data Definition queries are a very powerful tool in the SQL language and can perform many tasks on the structure of a database without recourse to VBA programming. SQL Can Make Query Design Easier! The QBE grid of the Query design window is a very useful tool, but sometimes it is easier to write SQL directly into the SQL View than to try to represent it on the grid. An example of this is specifying the sort order of a query. Here is a (very) simple example to illustrate the point: Suppose you want to sort your query by two columns. In the QBE grid you specify the sort direction of each column: http://www.fontstuff.com/access/acctut14.htm 3/6
  • 4. 9/8/2014 Access Tips: Access and SQL Part 1: Setting the SQL Scene But Access determines the sort order by the position of the columns in the QBE and sorts left-to-right. Here the data is sorted first by Firstname then by Lastname. But what if you wanted to sort the other way? Rearranging the columns would mean that the Lastname field would appear before the firstname field and you might not want that! >>> The answer is to specify the correct sort order in the SQL: >>> The SQL SELEC T clause determines the order in which the data is displayed and the ORDER BY clause determines the sort order. Getting the desired sort order is simply a matter of editing the ORDER BY clause. Here's how you would have to represent that in the QBE grid: To get this result in using the QBE grid you have to enter additional columns (remembering to uncheck their "show" option). This is a very simple example. With multiple columns and a complex sort order there is a lot more to do. Whatever way you do it the result is the same. The data is displayed in the order Firstname, Lastname but the sort order is Lastname, Firstname. NOTE: When you make changes the query's SQL view Access modifies the QBE grid to represent the new SQL statement graphically. ^ top Do I need to know SQL? Most database users don't need to know SQL. Anyone who has built a anything but the most basic of queries using the Access query design window has already been using SQL without knowing it. C riteria like: Between #01/01/2003# AND #01/07/2003# or Not("London") or http://www.fontstuff.com/access/acctut14.htm 4/6
  • 5. 9/8/2014 Access Tips: Access and SQL Part 1: Setting the SQL Scene In("London", "Paris", "NewYork") are all phrases from the SQL language. Access contains many tools and wizards that hep the user create a powerful database without having to learn SQL. But if you are at all serious about database building (and the fact that you are reading this suggests that you are!) a knowledge of SQL will help you build better, more powerful databases. So my answer is an emphatic "YES!". But don't panic... this doesn't mean that you have to go on an SQL course right away, or even buy a book (although there are plenty of excellent books and online resources on the subject). I started learning SQL by building queries in the Access query design window, then looking at the SQL that was Access generated in the SQL View. It's an excellent way to learn the basics. And if you follow this series of tutorials you should learn enough to help you figure out the rest yourself. ^ top Online Resources for SQL There is plenty of SQL reference material available free on the web. Just go to your favourite search engine and type in "SQL tutorial" for a (large) selection. I had planned to include a selection here but most of them are pretty turgid and don't make easy reading. Whilst I suppose it isn't fair to complain when it's free, it is often difficult to find the SQL amongst the plethora of adverts and pop-ups. Anyway, you've found me so you're in the best place! For an overview of SQL try W3 Schools - Learn SQL which has introductory and advanced SQL tutorials at http://www.w3schools.com/sql/ ^ top Books on SQL Most good books on Microsoft Access and Access development will have a section on SQL so take a look at the Access page of my bookshelf section. I have only one book on SQL. I bought it when I was considering a project working with both Microsoft Access and Microsoft SQL Server, but it is an excellent and very readable introduction for the newcomer to SQL as well as a vital reference work for anyone considering working with both programs: SQL: Access to SQL Server Susan Sales Harkins, Martin Reid Apress ISBN: 1893115305 Find this book at Amazon.com (USA) Find this book at Amazon.co.uk (UK) ^ top What's Next? The next tutorial in this series will explain how to incorporate SQL into VBA code: Access and SQL Part 2: Putting VBA and SQL Together ^ top http://www.fontstuff.com/access/acctut14.htm 5/6