Reliable Spreadsheet Solutions - Call Now 281-379-2000 Microsoft Excel - Visual Basic for Applications Consultant Reliable Spreadsheet Solutions - Call Now 281-379-2000 !
PROFESSIONAL SOFTWARE DEVELOPMENT
Reliable Excel VBA Solutions !
 
Microsoft Office : Excel - Visual Basic for Applications [ VBA ] Software 

Beyond Technology

Insight for Microsoft Excel POWER-Users
  Excel Solutions Letter ® FREE  excel solutions letter
Spreadsheet Power-User Tips
  Enable ease and consistency of data entry with a dropdown list of possible entries for a range  dropdown list in cell
  Designing an array formula that functions similar to a VLOOKUP function with multiple criteria and returns a text entry  mult-criteria text lookup
  How Excel workbooks become bloated and what can be done about it  spreadsheet bloat
  Spreadsheet Power-User Tips  more ...
Getting to Know Microsoft Visual Basic for Applications
  Decision Structure that conditionally executes the embedded code  if...then[...else]
  If you are new to VBA and trying to get a handle on programming, this is a MUST READ article for you!  what are variables ?
  Discover a special, more flexible variety of arrays  dynamic arrays
  Getting to Know Microsoft Visual Basic for Applications  more ...
Microsoft Excel Advanced VBA - Just for Geeks
  MUST SEE!  A named range that expands and contracts automatically based on the number of items in the source data table  dynamic named ranges
  MUST SEE! How to identify the last used row in an Excel worksheet  finding real last cell
  Creating charts that adapt as the size of the source data range varies  charting dynamic data
  Microsoft Excel Advanced VBA - Just for Geeks  more ...
Excel Spreadsheet Tools and Tutorials
  Mortgage & Auto Loan Payment Calculator » Amortization with Excel Spreadsheets  amortization guide
  Breakeven Analysis with Excel Spreadsheets Tutorial  breakeven analysis
  Permutations & Combinations with Excel Spreadsheets  combinatorics
  Standard Deviation in Excel Spreadsheets Tutorial  standard deviation
  Weighted Average in Excel Spreadsheets Tutorial  weighted average


Microsoft Excel VBA Custom Application Development
  Microsoft Excel VBA Custom Application Development  excel vba customization
  Microsoft Excel VBA Professional Development Experience  professional experience
  Microsoft Excel VBA Custom Application Development  project request form
Microsoft Excel VBA Solutions : Real-World Project Profiles
  How deep is your data?  engineering analysis
  Financial reporting can be a challenging endeavor.  financial reporting
  To anticipate customers needs is to be rewarded with their business.  sales forecasting
  Are time-hungry paperwork tasks building up on you?  automated billing
  An Engineer-in-a-Box  engineering design
  Partial List of Beyond Technology Clients - Past & Present  clients - past & present


Reliable Spreadsheet Solutions - Call Now 281-379-2000 !
  Visitors' Comments  gratuitous kudos
  Add to Favorites 
  Reliable Spreadsheet Solutions - Call Now 281-379-2000 !  e-mail contact

20831 Rosehill Church Rd
Tomball, Texas 77377


SQL for the Rest of Us ( Part 1 of 5 )
Basics of a Selection Query


Rodney POWELL
Microsoft MVP - Excel
need a developer for
your excel project ?
go here
Structured Query Language (SQL), usually pronounced "sequel", was originally developed by IBM for its mainframes. It was adopted in 1986 as somewhat of an industry standard language for querying databases. Virtually all relational database systems on the market today support SQL. It enables developers to design almost any user interface as long as SQL is used to communicate with the database engine. Without SQL, users would be restricted to use whatever query interface the designer delivered with the database. If a database product supports SQL, you can build solutions with a fair a mount of interchangeability using components from different vendors whose software best meets your requirements. Microsoft has several database products in its product line, all of which are SQL compatible.

So, SQL is a language used for querying, updating, and managing relational databases. It enables you to manipulate data in an ad hoc manner using a fairly simple set of key words or commands. SQL can be used to retrieve, sort, and filter specific data from a database. Additionally, you can add, change, and delete data in a database using a SQL statement in the form of a string. You can even use a SQL statement to modify a database structure, such as table definitions and fields.

The four most common parts of a SQL statement are:

Purpose Example
1. Specify the fields (columns) to retrieve SELECT CustID, ShipAddr
2. Specify the source table or query recordset FROM Orders
3. Specify the record-selection criteria WHERE ShipState = "TX"
4. Specify a sort order ORDER BY CompanyName

A SELECT command is the basic building block of a query statements for retrieving data from database tables. It instructs the database engine to search the specified table(s) and extract the chosen fields. It can then also select rows that meet some criteria and sort or group the resulting rows into a specified order.

If you need more than one field returned in a result set, specify the fields by separating the names with commas. The FROM clause specifies the recordset from which the data will be gathered.
	SELECT [First Name],[Last Name] FROM Employees;
The square brackets [ ] around field or table names are only necessary when they contain spaces. Note also, the semicolon ( ; ) is used to indicate the end of the SQL statement.

You can include all fields from the table by using the * (asterisk) character instead of writing out the individual field names.
	SELECT * FROM Employees;
In addition to the basic SQL structure that specifies fields and a table, you may add other types of clauses to the statement. SQL statements often include the ORDER BY command, variations of JOIN clauses, INSERT, UPDATE, DELETE, and others. Probably the most common is the WHERE clause, which we'll examine first here.

The WHERE clause is optional. You can use a WHERE clause to specify conditions for the query and filter records before they are returned in the query's result set. It utilizes one or more comparison statements using operators such as =,>,<,>=,<=,<> or LIKE (for text comparisons) and BETWEEN...AND (for a range of values).

Here are examples of using a WHERE clause that only returns records with a field matching a particular criteria. Specify multiple criteria using the AND and OR keywords.

Date literals are always enclosed with pound signs ( # ):
	SELECT * FROM Employees
	WHERE HireDate >= #1/1/2000# AND Dependents = 0;
And, text data (string literals) need to be enclosed in single quotation marks. If you use double-quotes within the query string, the SQL interpreter will stop parsing the query when it reaches those double-quotes.:
	SELECT * FROM Employees
	WHERE LastName LIKE 'p*';
- or -
	SELECT * FROM Orders
	WHERE ShipState = 'TX' OR 'VA';
Notice that because Salary would be a numeric field, not text, the salaries are not enclosed in quotation marks.
	SELECT * FROM Employees
	WHERE Salary BETWEEN 20000 AND 40000;
There is also a WHERE clause with an IN operator that can determine whether the value of an expression is equal to any of several values in a list.
	SELECT * FROM Orders
	WHERE ShipState IN ('FL','TX','VA');

Reliable Spreadsheet Solutions - Call Now 281-379-2000 !

Something to add? Let me know.

Beyond Technology Custom Application Development
  home Microsoft Excel VBA Custom Application Development  professional consulting Insight for Microsoft Excel POWER-Users  developer tips Visitors Comments  visitor kudos Beyond Technology - Microsoft Solution Provider  e-mail  

Your suggestions and comments are greatly appreciated. Please keep them coming.

Mail to:   rodney@beyondtechnology.com

All terms, product designs, and company names used in this site may be trademarks or registered trademarks of their respective owners, and are hereby acknowledged. © 1996 - 2008 Beyond Technology. All rights reserved.