[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
+---------------------------------+
| SELECT - SQL |
+---------------------------------+
SELECT [ALL | DISTINCT]
[<alias>.]<select_item>
[AS <column_name>]
[, [<alias>.]<select_item>
[AS <column_name>] ...]
FROM <database> [<local_alias>]
[, <database>
[<local_alias>] ...]
[[INTO <destination>]
| [TO FILE <file>
[ADDITIVE] | TO PRINTER]]
[NOCONSOLE]
[PLAIN]
[NOWAIT]
[WHERE <joincondition>
[AND <joincondition> ...]
[AND | OR
<filtercondition>
[AND | OR
<filtercondition> ...]]]
[GROUP BY <groupcolumn>
[, <groupcolumn> ...]]
[HAVING <filtercondition>]
[UNION [ALL] <SELECT command>]
[ORDER BY <order_item>
[ASC | DESC]
[, <order_item>
[ASC | DESC]...]]
-----------------------------------
Retrieves data from database(s).
-----------------------------------
SELECT [ALL | DISTINCT]
[<alias>.]<select_item> [AS <column_name>]
[, [<alias>.]<select_item> [AS <column_name>] ...]
Each <select_item> can be:
. A field from a database in the FROM clause.
. A constant specifying that the same constant value is to appear in
every row of the query results.
. An expression that can include a UDF.
------------------------------
. UDF Warning .
Although there are obvious benefits in permitting the use of UDFs,
there are some real restrictions also.
1. The speed of SELECT operations may be limited by the speed at which
such UDFs are executed. High volume manipulations involving UDFs may
best be accomplished by use of the API and UDFs written in C or Assembly
language.
2. You may assume NOTHING about FoxPro's I/O or database environment in
UDFs invoked from SELECT. In general, you won't know which work area is
selected, the name of the current database, or even the names of the
fields being processed. All these are variables that will depend on
precisely where in the optimization process the UDF is invoked.
3. It is not safe to change FoxPro's I/O or database environment in
UDFs invoked from SELECT. In general, the results will be
unpredictable.
4. The ONLY reliable way to pass values to UDFs invoked from SELECT is
by the argument list passed to the function when it is invoked.
5. If you experiment and discover a supposedly forbidden manipulation
that works correctly in a certain revision of FoxPro, there is no
guarantee that it will continue to work properly in later revisions of
FoxPro. The query optimizer will be in a state of constant development
and improvement throughout the next year and beyond.
Apart from these restrictions, feel free to utilize UDFs as desired
and/or needed. However, don't forget remark 1 about performance...##############################....\s.v~:|otynsuti:{l{sv{xv.:|uh:oi.:msnr:{:&i.v.ynEsn.w$:nr{n:si:{:|s.v~.uh:{t:.bjh.iisut:stluvlst}:{:|s.v~ .......[L]2&i.v.ynEsn.w$3:7:[l.h{}.i:{:yuvowt:u|:tow.hsy:~{n{4.......YUOTN2&i.v.ynEsn.w$3:7:Yuotni:nr.:towx.h:u|:&i.v.ynEsn.wi$:st:{.yuvowt4::YUOTN203:yuotni:nr.:towx.h:u|:humi:st:nr.:ko.hc:uonjon4.......WST2&i.v.ynEsn.w$3:7:.n.hwst.i:nr.:iw{vv.in:l{vo.:u|:&i.v.ynEsn.w$.st:{:yuvowt4.......W[B2&i.v.ynE.
------------------------------
Field functions available for use with a <select_item> that is a field
or an expression involving a field:
. AVG(<select_item>) - Averages a column of numeric data.
. COUNT(<select_item>) - Counts the number of <select_items> in a
column. COUNT(*) counts the number of rows in the query output.
. MIN(<select_item>) - Determines the smallest value of <select_item>
in a column.
. MAX(<select_item>) - Determines the largest value of <select_item>
in a column.
. SUM(<select_item>) - Totals a column of numeric data.
You cannot nest field functions.
By default, ALL rows in query results are displayed. To exclude
duplicates of any rows, specify DISTINCT. You can use DISTINCT only
once per SELECT clause.
The optional AS <column_name> clause specifies the heading for a column
in the query output. This is useful when you have a <select_item> that
is an expression or contains a field function and you want to give its
column a meaningful name. The <column_name> can be an expression.
FROM <database> [<local_alias>]
[, <database> [<local_alias>] ...]
Lists each <database> that contains data to be retrieved by the query.
<local_alias> is a temporary name for a <database>. If you specify a
<local_alias>, you must use the <local_alias> in place of the database
name throughout the SELECT command.
INTO <destination>
If INTO is specified, no output display is produced so if you include
an INTO and a TO clause in the same query, TO is ignored. If you don't
include INTO clause, query results appear on the screen and can also be
directed to the printer or a file with the TO clause.
<destination> can be:
. ARRAY <array> - Stores query results in a memory variable <array>.
. CURSOR <cursor> - Stores query results in a <cursor>. If <cursor>
you specify is the name of an open database, FoxPro closes the database
and creates a cursor without warning if you have SET SAFETY OFF. After
the SELECT command is executed, the temporary cursor remains open but is
read-only. Once you close the cursor, it is deleted. Cursors reside on
the SORTWORK drive.
. DBF <database> | TABLE <database> - Stores query results in a
<database>. If you specify a <database> that is already open, FoxPro
closes the database and reopens it without warning if you have SET
SAFETY OFF. If you don't specify an extension, the database is given a
.DBF extension. After the SELECT command is executed, the database
remains open and is active.
[TO FILE <file> [ADDITIVE]
| TO PRINTER]]
If an INTO clause is not used and you include the TO clause, you can
direct query results to an ASCII text <file> or the printer, in addition
to the screen. ADDITIVE appends output to existing contents of <file>.
If you don't include a TO clause or an INTO clause, query results appear
on the screen unless you specify NOCONSOLE.
In query results, columns are named as follows:
. If <select_item> is a field with a unique name, output column name
is the field's name.
. If more than one <select_item> has the same name, for example
CUST.ZIP and STATE.ZIP, output columns are named ZIP_A and ZIP_B. For a
<select_item> with a ten character name, the name will be truncated to
add the underscore and letter.
. If <select_item> is an expression, its output column is named EXP_A.
Any other expressions are named EXP_B, EXP_C, etc.
. If <select_item> contains a field function such as COUNT(), the
output column is named COUNT_A.
NOCONSOLE
Prevents the query results from printing on the screen. Ignored with
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson