SQL is a database programming language that gives you the controls you need to pull data. While the basics of SQL are the same regardless of your database type, there are a few things specific to Access SQL.
One of the best known programming languages is the Structured Query Language, or SQL. Some would even say it is essential for any programmer to know. It is certainly essential if you are responsible for managing a database.
If you are responsible for a database with multiple Access users, you need to know more than just SQL. You need to know about the elements that are specific to Microsoft Access. It is also important to have an expert you can contact if you have issues with your SQL queries. It is possible that you will need to repair Access error, and a second set of eyes can catch things that you may not see or is very unusual.
Quick Lesson in What SQL Is
SQL is a language specifically designed for working with relational databases, like Access. It is one of the most popular computer languages for novices to learn because of the simplicity of the structure and syntax.
The purpose of SQL is to create queries that specify the kind of data you want to review and analyze. Syntax is essential for successfully completing this task.
The SELECT Statement
One of the most commonly used elements of SQL is the SELECT statement. This is what describes the data to be pulled. Every element of the data that is needed is described within the SELECT statement.
- Tables where the data is stored
- The relationship between the data from the various sources
- All calculations and fields required to generate the data
- Data criteria for inclusion
- Method of sorting, if applicable
The SQL Clause
The SQL clause is comparable to the parts of a sentence. SQL statements are composed of different clauses.
There are many SQL clauses. As a beginner, you don’t need to know all of them right off of the bat. The following list contains the most common clauses you will need for your SQL queries.
- SELECT – specifies the data field; it is a required element (you must have at least one SELECT clause in your query).
- FROM – specifies the tables where the SELECT data fields are; it is also required.
- WHERE – required field criteria for each record that will be returned by the query.
- ORDER BY – details the sorting order of the results.
There are two more difficult SQL clauses that are helpful to understand. These clauses deal with aggregate information.
- GROUP BY – SQL statement with aggregate functions providing a list of fields not provided in the SELECT clause.
- HAVING – SQL statement with aggregate functions providing the applicable conditions for the fields summarized by the SELECT statement.
Like any language (computer or spoken), you need a vocabulary. This is where terms come in. Terms can be many, many things, but there are several different types of terms.
- Identifier – They act like a noun. Name your identifier to specify a particular database object. Fields are the most obvious type of database object.
- Constant – These also act like nouns, but with a specific purpose. Constants never change, with the NULL being a commonly used constant. You can also use numbers as they only have one meaning that does not change.
- Operator – Operators act like verbs or adverbs. It specifies the action that is to be run or modifies an existing action in the query.
- Expression – Expressions act like adjectives. They can be any combination of the other terms that result in one value.
This provides the basics of what you need to understand Access SQL syntax. The next article goes into more detail of how to use these and provides an example so you can try it out yourself.
Victor Ren is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including Excel file repair and word recovery software products. For more information visit www.datanumen.com