
APPENDIX 151
TableOne and TableTwo, each contain four columns (the data types of these columns are
usually not necessary to know):
TableOne – One, Two, ree, Four
TableTwo – Five, Six, Seven, Eight
A basic SELECT query, which will grab all data rows and columns from TableOne, will look
like this:
SELECT * from TableOne
e “*” character represents a desire to have all columns and all rows from TableOne. is
basic query is usually unnecessary because TaskBuilder operations default to a “select all”
without needing to write a specic SQL statement. If you want all information in TableOne,
the regular TaskBuilder behavior can be used without writing SQL.
Selecting One or More Columns From a Table
If you desire columns One and Four from TableOne, but not Two and ree, then replace
the “*” with the specic column names separated by commas:
SELECT One, Four from TableOne
You can specify an unlimited number of columns in a SELECT statement. If desired, you
can also select columns more than once:
SELECT Two, Three, Four, Two from TableOne
e resulting data set will have four columns with data from column Two being in both the
rst and last columns. is is redundant, but the option is available.
Selecting One or More Data Rows From a Table
Another common operation is selecting only certain rows that meet certain criteria from
the data table. To add a qualier to the query, use a WHERE clause; strings must be en-
closed in single quotation marks:
SELECT * from TableOne WHERE One > 100
SELECT * from TableTwo WHERE Six = ‘Hello’
e data types of each column will need to be known for WHERE statements to be created.
An error will occur in column six if the WHERE Six = ‘Hello’ statement contains integers.
e query will return an empty set if the data row does not meet the criteria.
Multiple WHERE clauses can be used by conjoining them with either the AND or OR
keywords:
Kommentare zu diesen Handbüchern